teaser
a small first-semester exercise
Description
A Knobelaufgabe, the kind of small exercise you get on the first problem sheets of a computer science degree. Pen and paper are enough. Each part you solve sets one of the site's hidden bits.
Here is a function in Python. // divides and rounds down, % is the remainder.
def mystery(n):
if n == 0:
return 0
return mystery(n // 2) + n % 2
Exercises
-
(a) What does
mystery(2025)return? -
(b) What is the smallest
nfor whichmystery(n)returns 10?