How to resolve the algorithm Abundant, deficient and perfect number classifications step by step in the 360 Assembly programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Abundant, deficient and perfect number classifications step by step in the 360 Assembly programming language
Table of Contents
Problem Statement
These define three classifications of positive integers based on their proper divisors. Let P(n) be the sum of the proper divisors of n where the proper divisors are all positive divisors of n other than n itself.
6 has proper divisors of 1, 2, and 3. 1 + 2 + 3 = 6, so 6 is classed as a perfect number.
Calculate how many of the integers 1 to 20,000 (inclusive) are in each of the three classes. Show the results here.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Abundant, deficient and perfect number classifications step by step in the 360 Assembly programming language
Source code in the 360 programming language
* Abundant, deficient and perfect number 08/05/2016
ABUNDEFI CSECT
USING ABUNDEFI,R13 set base register
SAVEAR B STM-SAVEAR(R15) skip savearea
DC 17F'0' savearea
STM STM R14,R12,12(R13) save registers
ST R13,4(R15) link backward SA
ST R15,8(R13) link forward SA
LR R13,R15 establish addressability
SR R10,R10 deficient=0
SR R11,R11 perfect =0
SR R12,R12 abundant =0
LA R6,1 i=1
LOOPI C R6,NN do i=1 to nn
BH ELOOPI
SR R8,R8 sum=0
LR R9,R6 i
SRA R9,1 i/2
LA R7,1 j=1
LOOPJ CR R7,R9 do j=1 to i/2
BH ELOOPJ
LR R2,R6 i
SRDA R2,32
DR R2,R7 i//j=0
LTR R2,R2 if i//j=0
BNZ NOTMOD
AR R8,R7 sum=sum+j
NOTMOD LA R7,1(R7) j=j+1
B LOOPJ
ELOOPJ CR R8,R6 if sum?i
BL SLI <
BE SEI =
BH SHI >
SLI LA R10,1(R10) deficient+=1
B EIF
SEI LA R11,1(R11) perfect +=1
B EIF
SHI LA R12,1(R12) abundant +=1
EIF LA R6,1(R6) i=i+1
B LOOPI
ELOOPI XDECO R10,XDEC edit deficient
MVC PG+10(5),XDEC+7
XDECO R11,XDEC edit perfect
MVC PG+24(5),XDEC+7
XDECO R12,XDEC edit abundant
MVC PG+39(5),XDEC+7
XPRNT PG,80 print buffer
L R13,4(0,R13) restore savearea pointer
LM R14,R12,12(R13) restore registers
XR R15,R15 return code = 0
BR R14 return to caller
NN DC F'20000'
PG DC CL80'deficient=xxxxx perfect=xxxxx abundant=xxxxx'
XDEC DS CL12
REGEQU
END ABUNDEFI
You may also check:How to resolve the algorithm GUI/Maximum window dimensions step by step in the Groovy programming language
You may also check:How to resolve the algorithm Synchronous concurrency step by step in the Erlang programming language
You may also check:How to resolve the algorithm Hofstadter Figure-Figure sequences step by step in the zkl programming language
You may also check:How to resolve the algorithm Factors of an integer step by step in the Fish programming language
You may also check:How to resolve the algorithm Averages/Mean angle step by step in the VBA programming language