Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Every previous number can be at most half the next number. (2, 3, 10) is ineligible, because 2 > 3/2
It's up to you to write code that stays within the limits of the language you choose.
Some languages eliminate the current call frame when you do tail recursion (no further actions after the call returns), making it a jump to the top just like a loop. You can do this yourself in other languages as well through trampolining. Sometimes you can also write it so that you get
log(n)
call depth andlog2(1000000)
is about 20 so plenty of room if you do that. Probably not worth it though, easier to use a loop. A tail recursive function directly translates to a loop (set the new state then jump to the top)Hi there,
I wrote the function recursively, and it passed all the tests apart from 1. This is the error the feedback gave:
RecursionError: maximum recursion depth exceeded in comparison
Is recursion in general discouraged if we are using large inputs? Would a for cycle be a better alternative in this case?
i cant pass test i dont know why, so weird , i solved problem in js
ok, thx now i see :). Maybe add some more info...
Reverse numbers go as 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 111, 121,..., 717,727, 737,..., 909
100th is 909
i dont get, how from n = 100 you get 909?
I think that javascript has some issue with precision, maybe the creator used a program to generate tests and that program had a precsion problem
JS version:
(expected 212212 to equal '224212.12')
I failed only 1 random test and get this info.
My result is 212212.
Why does it expect to return a decimal?
Try googling palindromic numbers, it might make more sense.
nice kata
Because it's a "polyfill" of ES6's built-in BigInt class
This comment is hidden because it contains spoiler information about the solution
Great! Thanks for the best advice ever!=)))
Try doing it by hand first. Then let the computer do what you did.
Loading more items...