How to resolve the algorithm Abundant odd numbers step by step in the Maple programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Abundant odd numbers step by step in the Maple programming language

Table of Contents

Problem Statement

An Abundant number is a number n for which the   sum of divisors   σ(n) > 2n, or,   equivalently,   the   sum of proper divisors   (or aliquot sum)       s(n) > n.

12   is abundant, it has the proper divisors     1,2,3,4 & 6     which sum to   16   ( > 12 or n);        or alternately,   has the sigma sum of   1,2,3,4,6 & 12   which sum to   28   ( > 24 or 2n).

Abundant numbers are common, though even abundant numbers seem to be much more common than odd abundant numbers. To make things more interesting, this task is specifically about finding   odd abundant numbers.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Abundant odd numbers step by step in the Maple programming language

Source code in the maple programming language

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));

  

You may also check:How to resolve the algorithm Multiple distinct objects step by step in the Lua programming language
You may also check:How to resolve the algorithm MAC vendor lookup step by step in the Scala programming language
You may also check:How to resolve the algorithm Stack step by step in the Ol programming language
You may also check:How to resolve the algorithm Strip whitespace from a string/Top and tail step by step in the Crystal programming language
You may also check:How to resolve the algorithm Non-decimal radices/Output step by step in the AutoHotkey programming language