Given two arbitrary integers \$a\$ and \$b\$, count how many numbers are divisible by perfect numbers in that given range (\$a\$ and \$b\$ both are inclusive).
In mathematics, a perfect number is a positive integer that is the sum of its proper positive divisors, that is, the sum of the positive divisors excluding the number itself.Equivalently, a perfect number is a number that is half the sum of all of its positive divisors (including itself), or \$σ(n) = 2n\$.
Input:
1 100
Output:
18
- Use stdin and stdout for Input/Output
- Your code must handle big integers, so it is not good enough to hard-code a list of perfect numbers.
- Shortest code wins
18
is not a perfect number! I guess you meant28
? (Since18!=9+6+3+2+1
, while28=14+7+4+2+1
). \$\endgroup\$Count how many numbers are divisible by perfect numbers
\$\endgroup\$1
is perfect... \$\endgroup\$