Guest User

Untitled

a guest
Jun 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. // Warning: maximum value for a variable of type int: 2,147,483,647
  2. #include <stdio.h>
  3. int main(int argc, char *argv[]){
  4. if(argc == 2){
  5. int x = atoi(argv[1]); int n = 0; printf("%i %i\n",n,x);
  6. if(x < 1){
  7. exit(1);
  8. }
  9. else{
  10. while(x != 1){
  11. if(x%2 == 0){
  12. x = x/2; n++; printf("%i %i\n",n,x);
  13. }
  14. else{
  15. x = (3*x)+1; n++; printf("%i %i\n",n,x);
  16. }
  17. }
  18. }
  19. }
  20. else{
  21. exit(1);
  22. }
  23. }
Add Comment
Please, Sign In to add comment