Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Warning: maximum value for a variable of type int: 2,147,483,647
- #include <stdio.h>
- int main(int argc, char *argv[]){
- if(argc == 2){
- int x = atoi(argv[1]); int n = 0; printf("%i %i\n",n,x);
- if(x < 1){
- exit(1);
- }
- else{
- while(x != 1){
- if(x%2 == 0){
- x = x/2; n++; printf("%i %i\n",n,x);
- }
- else{
- x = (3*x)+1; n++; printf("%i %i\n",n,x);
- }
- }
- }
- }
- else{
- exit(1);
- }
- }
Add Comment
Please, Sign In to add comment