0

Hofstadter's Q-Sequence - Issue

Hi, I was writing a code for a code coach task and unexpectedly got stuck with solution for Hofstadter's Q-Sequence. I wrote a tiny recursion for this. But once clicked Run button only two tests were passing. I got back to my code and spend some more time (that was interesting but still time consuming) and what I found out was my recursion works up until Q(31). After that it does not return any value. Thus, is there any cap of memory allocated for the task, which prevents recursion from diving deeper?

23rd Jan 2020, 7:55 AM
viktoras ciumanovas
viktoras ciumanovas - avatar
2 ответов
+ 3
Use Alexandr 's idea from this post https://www.sololearn.com/Discuss/2113151/?ref=app
23rd Jan 2020, 8:07 AM
Mihai Apostol
Mihai Apostol - avatar
+ 1
Thank you Mihai Apostol Thought so! Yes I know we can solve that without recursion. But we will loose all beauty of it :) anyways - thanks for quick reply. will go and rewrite the code ;)
23rd Jan 2020, 8:11 AM
viktoras ciumanovas
viktoras ciumanovas - avatar