Giuga numbers: Difference between revisions

Added BASIC256
(Created Nim solution.)
(Added BASIC256)
Line 117:
Giuga numbers 1-4: 30 858 1722 66198
</pre>
 
=={{header|BASIC256}}==
<syntaxhighlight lang="vb">n = 3
c = 0
limit = 4
print "The first"; limit; " Giuga numbers are: ";
do
if isGiuga(N) then c += 1: print n; " ";
n += 1
until c = limit
end
 
function isGiuga(m)
n = m
f = 2
l = sqr(n)
while True
if n mod f = 0 then
if ((m / f) - 1) mod f <> 0 then return false
n /= f
if f > n then return true
else
f += 1
if f > l then return false
end if
end while
end function</syntaxhighlight>
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
=={{header|C++}}==
2,130

edits