SHARE
TWEET

Untitled

a guest Feb 17th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top