Skip to content
Snippets Groups Projects

B1001

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Kiryuu Sakuya
    main.c 287 B
    #include <stdio.h>
    
    int main(void) {
        // 3n + 1
        int n, k = 0;
        scanf("%d", &n);
        do {
            if (n % 2 == 0) {
                n = n / 2;
            }
            else {
                n = (n * 3 + 1) / 2;
            }
            k++;
        } while (n != 1);
        printf("%d", k);
        return 0;
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment