Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Shortz(n) {
- var x = 0;
- while(n != 1) {
- x++;
- if(n % 2 == 0 && n != 0) {
- n = parseInt(n / 4);
- }
- else n = n * 3 + 1;
- console.log(n);
- }
- return x;
- }
- function ShortzSum(n) {
- var x = n;
- while(n != 1) {
- if(n % 2 == 0 && n != 0) {
- n = parseInt(n / 4);
- }
- else n = n * 3 + 1;
- x += n;
- console.log(n);
- }
- return x;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement