Created
November 13, 2015 02:30
-
-
Save f3r/4361f33c8033ed8e1345 to your computer and use it in GitHub Desktop.
Mu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://mathworld.wolfram.com/MultiplicativePersistence.html | |
var prod = function(num){ | |
return num.toString().split('').reduce(function(prev, cur){ | |
return prev*cur; | |
}) | |
} | |
var mp = function(num) { | |
if (num < 10) { return 0 } | |
else { return 1 + mp(prod(num)) } | |
} | |
mp(39); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment