Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 4
The 'add' function is called technically called thrice. The 'add' function is first called twice, and then both the returned values are again passed to the 'add' function
func -> add
func(5, 10) -> add(5, 10) -> 15
Inside the do_twice function:
func(func(5, 10), func(5, 10))
-> add(add(5, 10), add(5, 10))
-> add(15, 15)
-> 30
+ 3
Yes you're right. 'func', which corresponds to 'add' is called twice with arguments (5, 10).
Both those calls return the sum 5 + 10 = 15
Then both the 15s are again passed to 'func' which are added and return 15 + 15 = 30