Advertisement
31ph4n70m

Neumann's_Random_Generator.coffee

Dec 19th, 2019
3,562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # coffeescript solution to codeabbey challenge 24
  2. inp2 = [3488, 373, 5368, 751, 8342, 3416, 843, 6173, 7019, 381, 1054, 6303]
  3. counter = 0
  4. rsp = []
  5. vals = []
  6. aux = 0
  7. aux2 = 0
  8. for i, j in inp2
  9.     aux = i
  10.     while true
  11.         aux2 = Math.trunc((aux * aux / 100) % 10000)
  12.         if aux in vals
  13.             rsp.push counter
  14.             break
  15.         vals.push aux
  16.         counter += 1
  17.         aux = aux2
  18.     counter = 0
  19.     vals = []
  20. console.log(rsp.join(" "))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement