Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
|
|
@ -1,35 +0,0 @@
|
|||
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 $
|
||||
28
Task/Giuga-numbers/Lua/giuga-numbers.lua
Normal file
28
Task/Giuga-numbers/Lua/giuga-numbers.lua
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
do --[[ find the first 4 Giuga numbers, composites n such that all their
|
||||
distinct prime factors f exactly divide ( n / f ) - 1
|
||||
|
||||
each prime factor must appear only once, e.g.: for 2:
|
||||
[ ( n / 2 ) - 1 ] mod 2 = 0 => n / 2 is odd => n isn't divisible by 4
|
||||
similarly for other primes
|
||||
]]
|
||||
|
||||
local gCount, n = 0, 2
|
||||
while gCount < 4 do
|
||||
n = n + 4 -- assume the numbers are all even
|
||||
local fCount, f, isGiuga, v = 1, 1, true, math.floor( n / 2 )
|
||||
while f <= ( v - 2 ) and isGiuga do
|
||||
f = f + 2
|
||||
if v % f == 0 then -- have a prime factor
|
||||
fCount = fCount + 1
|
||||
isGiuga = ( math.floor( n / f ) - 1 ) % f == 0
|
||||
v = math.floor( v / f )
|
||||
end
|
||||
end
|
||||
if isGiuga then -- n is still a candidate, check it is not prime
|
||||
if fCount > 1 then
|
||||
gCount = gCount + 1
|
||||
io.write( " ", n )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
3
Task/Giuga-numbers/Sidef/giuga-numbers.sidef
Normal file
3
Task/Giuga-numbers/Sidef/giuga-numbers.sidef
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
4..Inf `by` 2 -> lazy.grep {|n|
|
||||
n.factor.all {|p| p `divides` (n/p - 1) }
|
||||
}.first(4).say
|
||||
Loading…
Add table
Add a link
Reference in a new issue