#include <stdio.h>
#include <stdlib.h>
void print_usage(void);
int main(int argc, char *argv[]) {
if (argc < 2) {
print_usage();
return -1;
}
int n = atoi(argv[1]);
while (n != 1) {
if (n % 2 == 0) {
n = n / 2;
} else {
n = n * 3 + 1;
}
printf("%d ", n);
}
printf("/n");
return 0;
}
void print_usage(void) {
printf("usage: 3n_1 13/n");
}
~
3n+1
最新推荐文章于 2023-10-30 19:05:29 发布