Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function hash(N) {
  2.     N = Math.abs(N);
  3.     N = N + '';
  4.     N = N.replace('.','');
  5.  
  6.     let sum = 0;
  7.  
  8.     do {
  9.         N = N + '';
  10.         N = N.split('').map(Number);
  11.         sum = N.reduce((sum, d) => sum + Number(d));
  12.         N = sum;
  13.         sum = 0;
  14.     } while (N > 9)
  15.  
  16.     console.log(N);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement