5 solutions

  • 0
    @ 2024-9-11 21:18:35

    #include <stdio.h>

    int main() { int n, s = 0; scanf("%d", &n); while (1) { if (n % 2!= 0) { s = n * 3 + 1; printf("%d*3+1=%d\n", n, s); } else { s = n / 2; printf("%d/2=%d\n", n, s); } if (s == 1) { break; } n = s; } printf("End"); return 0;

    Information

    ID
    6752
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    7
    Tags
    (None)
    # Submissions
    422
    Accepted
    82
    Uploaded By