Skip to content

Latest commit

 

History

History

Machine Fix

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

The program works as follow:

  • For every number n, n and n - 1 are converted to base 3
  • The program compare the digits, the number of differences is added to total

By observation, we can see that:

  • For every number n, most of the time the difference is 1
  • If n is divisible by 3, the difference is 2
  • If n is divisible by 3, the difference is 3, and so on

Final program:

def count3(n):
    sum = 0
    while (n > 0):
        sum += n
        n //= 3
    return sum

print(count3(523693181734689806809285195318))

Flag: csictf{785539772602034710213927792950}