Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

persistent bugger javascript code

function persistence(num) {
    const digits = `${num}`.split("");
    if (digits.length === 1) {
        return 0;
    }

    const product = digits.reduce((product, digit) => {
        return product * digit;
    }, 1);

    return 1 + persistence(product);
}
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #persistent #bugger #javascript #code
ADD COMMENT
Topic
Name
8+7 =