18 lines
839 B
Plaintext
18 lines
839 B
Plaintext
solve with HSgpt:
|
||
|
||
TL;DR
|
||
The program is a tiny “Collatz‑step” challenge.
|
||
|
||
main creates two random numbers:
|
||
N = 1 000 000 + random() – a large (≈ 1 million) starting value.
|
||
k = abs( (random() & 0xFF) ) – a small non‑negative integer (0‑255).
|
||
func0 prints “Challenge: N k\n>>> ”, reads an integer answer from stdin, calls func1(N,k), and checks whether the returned value equals answer. If it does, it prints “Correct.” and returns 0; otherwise it prints “Wrong.” and returns 1.
|
||
func1 implements k iterations of the Collatz (3n+1) map on the value n that is passed in w0.
|
||
|
||
|
||
Challenge: 524465851 157
|
||
The result after performing 157 Collatz‑steps on the starting value 524 465 851 is: 526
|
||
Challenge: 1871541254 68
|
||
Result after 68 Collatz steps: 30046216
|
||
|