is there a story as to why this is "infernal"?
I hate recursion, so it is all infernal to me! Iteration is the way to go...
Test suite could helpfully include n=1 and n=2 tests. I thought that it needed extra complexity to handle these, but @bmtran's top solution shows it doesn't.
I spend a lot of time to get the correct R from the example. The issue is that you say k = 5/9 instead of 4/9 . Just a typo to correct . Thanks
cheat this one because I think my answer wasn't wrong despite the stupidity, wonder if why this insanely slow.
"Recursion" in title had me in a really tricky detour.
it cost much too time,so .....
Fails for both n=1 and n=2?
holy moly, you posted this one mere seconds after i posted mine.
Fails for n=1?
that was a photo-finish :)
OK for both n=1 and n=2.
Solve the Sudoku Row
Back to basics 17 - white space
Is it a number?
Circle and Quadratic
Return the Fibonacci Sequence
Spiraling out of control....
Find the repeating decimal pattern!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office