Ad
  • Custom User Avatar

    It's a math precision issue. This is about integer arithmetics, floating point doesn't work.

    2^31 * 17^2 * 969743 * 25772783 = 15511210043330986055303168
    25! = 15511210043330985984000000 = 2^22 * 3^10 * 5^6 * 7^3 * 11^2 * 13 * 17 * 19 * 23

  • Default User Avatar

    Having same issue. 25! results in 2^31 * 17^2

    I am suspecting the fact that it's a big number somehow fools my tests . I am currently using this to see if a number is divisible entirely by another
    float_div = factorial / prime
    if float_div == int(float_div):
    #carry on dividing by same prime

    Anyone can give me a hint of what i am doing wrong?
    thanks

  • Custom User Avatar

    @g964
    I have exactly the same error. When I decompose a number n into its prime factors I should take the biggest powers of its prime and then dived by the next prime and so on. In this case the biggest power is of 2 is 31. I can say it differently. The number 3^10 * 5^6 * 7^3 * 11^2 * 13 * 19 * 23 is diveded by 2 (9 more times), so I cant move on to the next prime (3) till I end the devision by 2.
    Thanks for your time.

  • Default User Avatar

    "EDIT: I have found that 1551121e25 is 25 factorial."

    No, it's not.

  • Custom User Avatar

    There is still a typo "iser_id" in the Note at very bottom of the instructions.

  • Default User Avatar

    All languages have the decomposition of factorial(25) and 1571 people passed the kata...

    I think that is an issue

    You think... Don't post issues unless you are absolutely sure of your code and sure that all other codes are wrong. ost simply a question.

  • Custom User Avatar

    It's a loop inside another. And you have to take care also how internally array_shift works, maybe it changes the index of all the array elements. Your code is almost there, try not using array_shift.

  • Custom User Avatar

    array_sum is a loop-alike method, so your code is O(n2). Please, read the posts below before creating your own, you're not the only one with that problem and it's been asked and answered several times already, mostly they post like you, with code so most of them are marked as having spoiler content and can't be seen for people who didn't complete the kata. Your code needs to be O(n) to pass.

  • Custom User Avatar

    It's in the initial code:

    SELECT * FROM greetings;