Daily Coding Challenge - Infected

Tell us what’s happening:

I think my code is right, but the modulus statement never runs. What’s happening?

Your code so far

def infected(days):
    computers = 1
    i = 0
    while i < days:
        computers *= 2
        if i%3 == 0:
            computers = computers - round(computers*0.2)
        i+=1
    return computers

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36

Challenge Information:

Daily Coding Challenge - Infected
https://www.freecodecamp.org/learn/daily-coding-challenge/2025-11-02

the if execute, the issue you have is a different one: you are never curing enough computers

Round the number of patched computers up to the nearest whole number.

Also: you are doubling infected computers also on day 0, which is not what should happen

You have already handled Day 0 by setting computers to 1, but by then starting your loop counter at 0, you are throwing everything off. And round isn’t that same as rounding up to the nearest integer.

thats why i used less than

that works for the while, not for counting each third day at which to calculate the patched computers

i swapped the i in the modulus with i+1 and only the last one is unsatisfied

did you fix the rounding?

I didn’t change anything, except for what I said I changed. Also, the last value is off by a lot

well, why don’t you try with fixing the rounding? you are not rounding up to the nearest integer