Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def f(n: int):
- if n == 0:
- return 0
- elif n > 0 and n % 2 == 0:
- return f(n // 2)
- elif n > 0 and n % 2 == 1:
- return f(n - 1) + 1
- count = 0
- for n in range(1, 501):
- if f(n) == 8:
- count += 1
- print(count)
Add Comment
Please, Sign In to add comment