Update primes.mga

This commit is contained in:
2021-10-02 15:56:23 +02:00
committed by GitHub
parent 8f196de1c4
commit 446296a5a8

View File

@@ -1,23 +1,34 @@
INT tot INT i
INT n
INT j INT j
INT te INT n
IN INT tot numero massimo INT c
SET n 1 INT modr
:scn
SET j 2 IN INT n Enter the number till which you want prime numbers\n
OUT $n$\n
:sieve OUT Prime numbers are:\n
MOD n j te
#OUT \n- $te$ -\n SET i 2
JME scr j n :loopi
SET c 0
SET j 1
:loopj
MOD i j modr
JE increasec modr 0
:increasecback
INC j 1 INC j 1
JM sieve te 0 JLE loopj j i
INC n JE printn c 2
JLE scn n tot :printback
INC i 1
JLE loopi i n
END END
:scr :increasec
#OUT $j$ sas\n INC c 1
SET j 2 JMP increasecback
INC n
JMP sieve :printn
OUT $i$\n
JMP printback