abundantNumbers.frink

Download or view abundantNumbers.frink in plain text format


/** This is a solver for Rosetta Code puzzle:
    "Abundant, deficient and perfect number classifications"
    https://rosettacode.org/wiki/Abundant,_deficient_and_perfect_number_classifications
*/


d = new dict
for n = 1 to 20000
{
   s = sum[allFactors[n, true, false, true], 0]
   rel = s <=> n
   d.increment[rel, 1]
}

println["Deficient: " + d@(-1)]
println["Perfect:   " + d@0]
println["Abundant:  " + d@1]


Download or view abundantNumbers.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 19945 days, 15 hours, 39 minutes ago.