Ad
  • Custom User Avatar

    Does anyone know what is the input for factorial 8?

  • Default User Avatar

    sorry, wrong testcase. @deconstrained already had the right hint

  • Default User Avatar

    Did it in JavaScript right now.
    No problems, no infinite loops.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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 as a-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.

  • Default User Avatar

    you are missing a space somehow
    There should be 2 spaces before the ^ on the second line

  • Custom User Avatar

    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

  • Custom User Avatar

    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.

  • Default User Avatar

    It's not infinite. There are 157 operations at all. Check your code.

  • Default User Avatar

    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.