Data update
This commit is contained in:
parent
ed705008a8
commit
0df55f9f24
2196 changed files with 32999 additions and 3075 deletions
|
|
@ -0,0 +1,33 @@
|
|||
// classify the numbers 1 : 20 000 as abudant, deficient or perfect
|
||||
"use strict"
|
||||
let abundantCount = 0
|
||||
let deficientCount = 0
|
||||
let perfectCount = 0
|
||||
const maxNumber = 20000
|
||||
// construct a table of the proper divisor sums
|
||||
let pds = []
|
||||
pds[ 1 ] = 0
|
||||
for( let i = 2; i <= maxNumber; i ++ ){ pds[ i ] = 1 }
|
||||
for( let i = 2; i <= maxNumber; i ++ )
|
||||
{
|
||||
for( let j = i + i; j <= maxNumber; j += i ){ pds[ j ] += i }
|
||||
}
|
||||
// classify the numbers
|
||||
for( let n = 1; n <= maxNumber; n ++ )
|
||||
{
|
||||
if( pds[ n ] < n )
|
||||
{
|
||||
deficientCount ++
|
||||
}
|
||||
else if( pds[ n ] == n )
|
||||
{
|
||||
perfectCount ++
|
||||
}
|
||||
else // pds[ n ] > n
|
||||
{
|
||||
abundantCount ++
|
||||
}
|
||||
}
|
||||
console.log( "abundant " + abundantCount.toString() )
|
||||
console.log( "deficient " + deficientCount.toString() )
|
||||
console.log( "perfect " + perfectCount.toString() )
|
||||
Loading…
Add table
Add a link
Reference in a new issue