Ad
  • Default User Avatar

    Thank you for the fast reply! I had made a basic error in thinking about how the totient works for non-coprime values.

    The Kata tests positive now (not for any virus, thankfully). Excellent Kata, by the way: just started using codewars, and it was a lot of fun training this Kata. Plus, I learned something interesting.

  • Default User Avatar

    6 × 6 % 8 = 4
    4 × 6 % 8 = 0
    0 × 6 % 8 = 0
    ==> 6^6 % 8 = 0

  • Default User Avatar

    On my attempt I receive a fairly odd failed test (for random inputs):

    Test tower(6, 2, 8)
    4 should equal 0

    Given that 6^6 mod 8 = 4 I am confident my code is correct in this case, while the Python test seems to be incorrect. My attempt also fails at multiple other tests for larger inputs, e.g.:

    Test tower(30318, 1648, 586)
    582 should equal 430

    Here I don't know which is correct, but a brute force tower code I wrote for testing using totient phi(586)=292 produces the same result as the optimised code, i.e. 582. Now I am wondering whether this, too, is an issue with the tests or with my attempt at a solution.