Advertisement
Hirsw0w

Untitled

Jun 10th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. function Shortz(n) {
  2. var x = 0;
  3. while(n != 1) {
  4. x++;
  5. if(n % 2 == 0 && n != 0) {
  6. n = parseInt(n / 4);
  7. }
  8. else n = n * 3 + 1;
  9. console.log(n);
  10. }
  11. return x;
  12. }
  13. function ShortzSum(n) {
  14. var x = n;
  15. while(n != 1) {
  16. if(n % 2 == 0 && n != 0) {
  17. n = parseInt(n / 4);
  18. }
  19. else n = n * 3 + 1;
  20.  
  21. x += n;
  22. console.log(n);
  23. }
  24. return x;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement