Record Case Detail

Notes

This function is in beta test. Please help improve it in the issues here.

Stderr


        

Hints

Your answer may be identical to the JOJ answer in the first several lines.

However, the main problem you meet now is Runtime Error. And the exit code of your program is -11, which should be 0.

Please double check your code to solve this problem and try again.

Your Answer

Running tests for hailstone...
Testing hailstone(5)
    Recursive: 5 16 8 4 2 1 
    Iterative: 5 16 8 4 2 1 
Testing hailstone(8)
    Recursive: 8 4 2 1 
    Iterative: 8 4 2 1 
Testing hailstone(14)
    Recursive: 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 
    Iterative: 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 
Running tests for count_digits...
Testing count_digits(2120, 2)
    Recursive:      0
    Iterative:      2
    Tail Recursive: 1
Testing count_digits(123, 7)
    Recursive:      0
    Iterative:      0
    Tail Recursive: 1
Testing count_digits(20, 0)
    Recursive:      0
    Iterative:      1
    Tail Recursive: 1
Testing count_digits(0, 8)

JOJ Answer

Running tests for hailstone...
Testing hailstone(5)
    Recursive: 5 16 8 4 2 1 
    Iterative: 5 16 8 4 2 1 
Testing hailstone(8)
    Recursive: 8 4 2 1 
    Iterative: 8 4 2 1 
Testing hailstone(14)
    Recursive: 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 
    Iterative: 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 
Running tests for count_digits...
Testing count_digits(2120, 2)
    Recursive:      2
    Iterative:      2
    Tail Recursive: 2
Testing count_digits(123, 7)
    Recursive:      0
    Iterative:      0
    Tail Recursive: 0
Testing count_digits(20, 0)
    Recursive:      1
    Iterative:      1
    Tail Recursive: 1
Testing count_digits(0, 8)
    Recursive:      0
    Iterative:      0
    Tail Recursive: 0
Testing count_digits(0, 0)
    Recursive:      1
    Iterative:      1
    Tail Recursive: 1