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?
2 ответов
+ 3
Use Alexandr 's idea from this post
https://www.sololearn.com/Discuss/2113151/?ref=app
+ 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 ;)