Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
35
Task/Giuga-numbers/Euler/giuga-numbers.euler
Normal file
35
Task/Giuga-numbers/Euler/giuga-numbers.euler
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
begin
|
||||
new for; new n; new gCount;
|
||||
for <- ` formal init; formal test; formal incr; formal body;
|
||||
begin
|
||||
label again;
|
||||
init;
|
||||
again: if test then begin body; incr; goto again end else 0
|
||||
end
|
||||
'
|
||||
;
|
||||
gCount <- 0;
|
||||
for( ` n <- 2 ', ` gCount < 4 ', ` n <- n + 4 '
|
||||
, ` begin
|
||||
new v; new f; new isGiuga; new fCount;
|
||||
v <- n % 2;
|
||||
isGiuga <- true;
|
||||
fCount <- 1;
|
||||
for( ` f <- 3 ', ` f <= v and isGiuga ', ` f <- f + 2 '
|
||||
, ` if v mod f = 0 then begin
|
||||
fCount <- fCount + 1;
|
||||
isGiuga <- [ [ n % f ] - 1 ] mod f = 0;
|
||||
v <- v % f
|
||||
end else 0
|
||||
'
|
||||
);
|
||||
if isGiuga then begin
|
||||
if fCount > 1 then begin
|
||||
gCount <- gCount + 1;
|
||||
out n
|
||||
end else 0
|
||||
end else 0
|
||||
end
|
||||
'
|
||||
)
|
||||
end $
|
||||
Loading…
Add table
Add a link
Reference in a new issue