Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main ()
  4. {
  5. int x;
  6. int i=0;
  7.  
  8.  
  9. printf ("Podaj X: ");
  10. scanf ("%d",&x);
  11.  
  12.  
  13. while(x!=1){
  14. if(x%2==0) {
  15. x=x/2;
  16. i++;
  17. }
  18. else {
  19. x=3*x+1;
  20. i++;
  21. }
  22. }
  23. printf ("Liczba operacji %d",i);
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement