How to resolve the algorithm Amicable pairs step by step in the VTL-2 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Amicable pairs step by step in the VTL-2 programming language
Table of Contents
Problem Statement
Two integers
N
{\displaystyle N}
and
M
{\displaystyle M}
are said to be amicable pairs if
N ≠ M
{\displaystyle N\neq M}
and the sum of the proper divisors of
N
{\displaystyle N}
(
s u m
(
p r o p D i v s
( N ) )
{\displaystyle \mathrm {sum} (\mathrm {propDivs} (N))}
)
= M
{\displaystyle =M}
as well as
s u m
(
p r o p D i v s
( M ) )
N
{\displaystyle \mathrm {sum} (\mathrm {propDivs} (M))=N}
.
1184 and 1210 are an amicable pair, with proper divisors:
Calculate and show here the Amicable pairs below 20,000; (there are eight).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Amicable pairs step by step in the VTL-2 programming language
Source code in the vtl-2 programming language
10 M=20000
20 I=1
30 :I)=1
40 I=I+1
50 #=M>I*30
60 I=2
70 J=I+I
80 :J)=:J)+I
90 J=J+I
100 #=M>J*80
110 I=I+1
120 #=(M/2)>I*70
130 I=1
140 J=:I)
150 #=(I
160 I=I+1
170 #=M>I*140
180 #=999
190 ?=I
200 $=9
210 ?=J
220 ?=""
230 #=!
You may also check:How to resolve the algorithm Formal power series step by step in the PARI/GP programming language
You may also check:How to resolve the algorithm Long year step by step in the Modula-2 programming language
You may also check:How to resolve the algorithm Repeat step by step in the FutureBasic programming language
You may also check:How to resolve the algorithm Caesar cipher step by step in the Microsoft Small Basic programming language
You may also check:How to resolve the algorithm Sum multiples of 3 and 5 step by step in the Perl programming language