def f(n): return n * 2 + 1 f(f(f(3))) 

This function returns us the number 31 in the form of an answer, maybe it just can’t understand why 31, thanks in advance!

  • 2
    ((3 * 2 + 1) * 2 + 1) * 2 + 1 = 31 - slippyk
  • @slippyk THANK YOU! - Andrey Sindeev

1 answer 1

The first call to f(3) will return 7.

3 * 2 + 1 = 7

Further, this number will become an argument for the next function f(7) and return 15.

7 * 2 + 1 = 15

And the third call f(15) returns 31.

15 * 2 + 1 = 31