Guest User

Untitled

a guest
Feb 17th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. function persistence(num) {
  2. let product = num
  3. let count = 0
  4. const splitNumArray = (product) => {
  5. return product.toString().split("").map(int => Number(int)).reduce((a, b) => a*b)
  6. }
  7. while (product >= 10) {
  8. product = splitNumArray(product)
  9. count++
  10. }
  11. return num < 10 ? 0 : count
  12. }
Add Comment
Please, Sign In to add comment