n = 8285 function solve(n) { // write code here var a = n.toString() var temp = a.split('') console.log(temp) function setNum(kk) { var sum = 0 for (key in kk) { sum += Math.pow(parseInt(kk[key]), 2) } return sum } //console.log(setNum(temp)) var done = setNum(temp) var setter = 0 while (setter < 100) { var u = done.toString() var v = u.split('') done = setNum(v) setter++ //console.log(done) } if(done == 1)return true else return false } console.log(solve(n))