+ 4
Hofstadter’s Q-Sequence in Code Coach
Only the first two checks Hofstadter’s Q-Sequence are passing with my code. Did anyone pass the full exercise with C# or att all?
8 Antworten
+ 5
Are you using recursion?
If yes, try to use for loop.
+ 5
I did it in C by storing the former results in an array instead of recreating them over and over recursively.
+ 5
Yes, I use the Recursive Algorithm. The results are correct, but from n=43 on the calculation time is obviously exceeded. So I will therefore use a different method.
Thanks for your tips.
+ 5
Guys, I made it. I taken a list and calculated the Q(n) in a "for" loop - as Denise Roßberg and HonFu mentioned, step by step for one "n", using the two results Q(n-1) and Q(n-2), that were in the list before. This algorithm is super fast. Now it calculates here for millions. For example Q(50,000,000) = 25,371,105. And that was not even the biggest (n) here. Thanks.
0
Cómo ASER que tú página salga ala red
0
Y