Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Attractive-numbers/XPL0/attractive-numbers.xpl0
Normal file
33
Task/Attractive-numbers/XPL0/attractive-numbers.xpl0
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
func IsPrime(N); \Return 'true' if N is prime
|
||||
int N, I;
|
||||
[if N <= 2 then return N = 2;
|
||||
if (N&1) = 0 then \even >2\ return false;
|
||||
for I:= 3 to sqrt(N) do
|
||||
[if rem(N/I) = 0 then return false;
|
||||
I:= I+1;
|
||||
];
|
||||
return true;
|
||||
];
|
||||
|
||||
func Factors(N); \Return number of factors for N
|
||||
int N, Cnt, F;
|
||||
[Cnt:= 0;
|
||||
F:= 2;
|
||||
repeat if rem(N/F) = 0 then
|
||||
[Cnt:= Cnt+1;
|
||||
N:= N/F;
|
||||
]
|
||||
else F:= F+1;
|
||||
until F > N;
|
||||
return Cnt;
|
||||
];
|
||||
|
||||
int C, N;
|
||||
[C:= 0;
|
||||
for N:= 4 to 120 do
|
||||
if IsPrime(Factors(N)) then
|
||||
[IntOut(0, N);
|
||||
C:= C+1;
|
||||
if rem(C/10) then ChOut(0, 9\tab\) else CrLf(0);
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue