How to resolve the algorithm Abundant odd numbers step by step in the XPL0 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Abundant odd numbers step by step in the XPL0 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 XPL0 programming language
Source code in the xpl0 programming language
int Cnt, Num, Div, Sum, Quot;
[Cnt:= 0;
Num:= 3; \find odd abundant numbers
loop [Div:= 1;
Sum:= 0;
loop [Quot:= Num/Div;
if Div > Quot then quit;
if rem(0) = 0 then
[Sum:= Sum + Div;
if Div # Quot then Sum:= Sum + Quot;
];
Div:= Div+2;
];
if Sum > 2*Num then
[Cnt:= Cnt+1;
if Cnt<=25 or Cnt>=1000 then
[IntOut(0, Num); ChOut(0, 9);
IntOut(0, Sum); CrLf(0);
if Cnt = 1000 then Num:= 1_000_000_001 - 2;
if Num > 1_000_000_000 then quit;
];
];
Num:= Num+2;
];
]
You may also check:How to resolve the algorithm Hello world/Text step by step in the Grain programming language
You may also check:How to resolve the algorithm Vector products step by step in the RPL programming language
You may also check:How to resolve the algorithm Order two numerical lists step by step in the Java programming language
You may also check:How to resolve the algorithm Singly-linked list/Traversal step by step in the Phix programming language
You may also check:How to resolve the algorithm Magic 8-ball step by step in the Wren programming language