Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
39
Task/Abundant-odd-numbers/Maple/abundant-odd-numbers.maple
Normal file
39
Task/Abundant-odd-numbers/Maple/abundant-odd-numbers.maple
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
with(NumberTheory):
|
||||
|
||||
# divisorSum returns the sum of the divisors of x not including x
|
||||
divisorSum := proc(x::integer)
|
||||
return SumOfDivisors(x) - x;
|
||||
end proc:
|
||||
|
||||
|
||||
# abundantNumber returns true if x is an abundant number and false otherwise
|
||||
abundantNumber := proc(x::integer)
|
||||
if (SumOfDivisors(x) > 2*x) then return true
|
||||
else return false end if;
|
||||
end proc:
|
||||
|
||||
count := 0:
|
||||
number := 1:
|
||||
|
||||
cat("First 25 abundant odd numbers");
|
||||
|
||||
while count < 25 do
|
||||
if (abundantNumber(number)) then
|
||||
count += 1:
|
||||
print(cat(count, ": ", number, " sum of divisors ", SumOfDivisors(number), " sum of proper divisors ", divisorSum(number)));
|
||||
else end if;
|
||||
number += 2:
|
||||
end:
|
||||
|
||||
while (count < 1000) do
|
||||
if (abundantNumber(number)) then
|
||||
count += 1:
|
||||
else end if:
|
||||
number += 2:
|
||||
end:
|
||||
|
||||
cat("The 1000th odd abundant number is ", number - 2, ", its sum of divisors is ", SumOfDivisors(number - 2), ", and its sum of proper divisors is ", divisorSum(number - 2));
|
||||
|
||||
for number from 10^9 + 1 by 2 to infinity while not abundantNumber(number) do end:
|
||||
|
||||
cat("First abundant odd number > 10^9 is ", number, ", its sum of divisors is ", SumOfDivisors(number), ", and its sum of proper divisors is ",divisorSum(number));
|
||||
Loading…
Add table
Add a link
Reference in a new issue