Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sum of product of digits of a given number

<script>
 
// JavaScript program to compute
// product of digits in the number.
 
// Function to get product of digits
function getProduct(n)
{
    let product = 1;
 
    while (n != 0)
    {
        product = product * (n % 10);
        n = Math.floor(n / 10);
    }
    return product;
}
 
// Driver code
let n = 4513;
 
document.write(getProduct(n));
 
// This code is contributed by Manoj.
 
</script>
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #sum #product #digits #number
ADD COMMENT
Topic
Name
7+6 =