Amicable pairs: Difference between revisions

Content deleted Content added
Added solution for Action!
Using Sieve of Eratosthenes module
Line 264: Line 264:
=={{header|Action!}}==
=={{header|Action!}}==
Calculations on a real Atari 8-bit computer take quite long time. It is recommended to use an emulator capable with increasing speed of Atari CPU.
Calculations on a real Atari 8-bit computer take quite long time. It is recommended to use an emulator capable with increasing speed of Atari CPU.
{{libheader|Action! Sieve of Eratosthenes}}
<lang Action!>DEFINE MAXNUM="20000"
<lang Action!>INCLUDE "H6:SIEVE.ACT"
BYTE ARRAY primes(MAXNUM+1)

PROC Sieve()
CARD i,j

SetBlock(primes,MAXNUM+1,1)
primes(0)=0 primes(1)=0 i=2
WHILE i<=MAXNUM
DO
IF primes(i)=1 THEN
FOR j=2*i TO MAXNUM STEP i
DO
primes(j)=0
OD
FI
i==+1
OD
RETURN


CARD FUNC SumDivisors(CARD x)
CARD FUNC SumDivisors(CARD x)
Line 303: Line 286:


PROC Main()
PROC Main()
DEFINE MAXNUM="20000"
BYTE ARRAY primes(MAXNUM+1)
CARD m,n
CARD m,n


Put(125) PutE() ;clear the screen
Sieve()
Sieve(primes,MAXNUM+1)
FOR m=1 TO MAXNUM-1
FOR m=1 TO MAXNUM-1
DO
DO