Find the sum of the number of divisors | Javascript code for above given approach ; To store the number of divisors ; Function to find the number of divisors of all numbers in the range 1 to n ; For every number 1 to n ; Increase divisors count for every number ; Function to find the sum of divisors ; To store sum ; Count the divisors ; Driver code ; Function call
let N = 100005 ; let mod = 1000000007 ; let cnt = new Array ( N ) ; cnt . fill ( 0 ) ; function Divisors ( ) { for ( let i = 1 ; i < N ; i ++ ) { for ( let j = 1 ; j * i < N ; j ++ ) { cnt [ i * j ] ++ ; } } } function Sumofdivisors ( A , B , C ) { let sum = 0 ; Divisors ( ) ; for ( let i = 1 ; i <= A ; i ++ ) { for ( let j = 1 ; j <= B ; j ++ ) { for ( let k = 1 ; k <= C ; k ++ ) { let x = i * j * k ; sum += cnt [ x ] ; if ( sum >= mod ) { sum -= mod ; } } } } return sum ; } let A = 5 , B = 6 , C = 7 ; document . write ( Sumofdivisors ( A , B , C ) ) ;