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.
Does anyone know what is the input for factorial 8?
sorry, wrong testcase. @deconstrained already had the right hint
Did it in JavaScript right now.
No problems, no infinite loops.
I didn't have any infinite loop in my JS solution. I don't think there's an actual issue with the test case, or else it has been solved since.
The code that is output if one prints it seems to differ from what code is actually being run, or there's an issue with copy/paste. I've tried copying into external editors only to find whitespaces missing. I believe that copying directly (at least on my system/browser) omits leading whitespace on lines, so I had to manually count the number of spaces and insert them.
Another possible cause of infinite looping (check the stack contents) is the order of operands in the non-commutative binary operators. If
-
is carried out asa-b
the result is an infinite series of-7,8...
accumulating in the stack. I ran into this and found out only after looking at the stack and my interpreter passed the test once I fixed this detail.you are missing a space somehow
There should be 2 spaces before the ^ on the second line
works for me as well, double check where you want to put an integer on a stack or value of ASCII, javascript is pretty hipster for programming
Factorial (8! = 40320)
08>:1-:v v *_$.@
^ _$>:^
Test Passed: Value == 40320
I'm not having a problem with this. But the Sieve of Eratosthenes is still not working for my interpreter.
It's not infinite. There are 157 operations at all. Check your code.
You need to be sure you are returning a number data-type and not a string. That's why the instructions explain "...Output should be returned as floating point number..."
(Hint: Remember that applying the toFixed() or toPrecision() methods to a number will return it as a string.)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number
I did go back and highlight that part of the kata's instructions though, so thank you for bringing that up.