Data update
This commit is contained in:
parent
ed705008a8
commit
0df55f9f24
2196 changed files with 32999 additions and 3075 deletions
63
Task/Duffinian-numbers/EasyLang/duffinian-numbers.easy
Normal file
63
Task/Duffinian-numbers/EasyLang/duffinian-numbers.easy
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
fastfunc isprim num .
|
||||
i = 2
|
||||
while i <= sqrt num
|
||||
if num mod i = 0
|
||||
return 0
|
||||
.
|
||||
i += 1
|
||||
.
|
||||
return 1
|
||||
.
|
||||
func gcd a b .
|
||||
while b <> 0
|
||||
h = b
|
||||
b = a mod b
|
||||
a = h
|
||||
.
|
||||
return a
|
||||
.
|
||||
func sumdiv num .
|
||||
d = 2
|
||||
repeat
|
||||
quot = num div d
|
||||
until d > quot
|
||||
if num mod d = 0
|
||||
sum += d
|
||||
if d <> quot
|
||||
sum += quot
|
||||
.
|
||||
.
|
||||
d += 1
|
||||
.
|
||||
return sum + 1
|
||||
.
|
||||
func isduff n .
|
||||
if isprim n = 0 and gcd sumdiv n n = 1
|
||||
return 1
|
||||
.
|
||||
return 0
|
||||
.
|
||||
proc duffs . .
|
||||
print "First 50 Duffinian numbers:"
|
||||
n = 4
|
||||
repeat
|
||||
if isduff n = 1
|
||||
write n & " "
|
||||
cnt += 1
|
||||
.
|
||||
until cnt = 50
|
||||
n += 1
|
||||
.
|
||||
cnt = 0
|
||||
n = 4
|
||||
print "\n\nFirst 15 Duffinian triplets:"
|
||||
repeat
|
||||
if isduff n = 1 and isduff (n + 1) = 1 and isduff (n + 2) = 1
|
||||
print n & " - " & n + 2
|
||||
cnt += 1
|
||||
.
|
||||
until cnt = 15
|
||||
n += 1
|
||||
.
|
||||
.
|
||||
duffs
|
||||
26
Task/Duffinian-numbers/PARI-GP/duffinian-numbers.parigp
Normal file
26
Task/Duffinian-numbers/PARI-GP/duffinian-numbers.parigp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
isDuffinian(n) = (!isprime(n)) && (gcd(n, sigma(n)) == 1);
|
||||
|
||||
testDuffinians()=
|
||||
{
|
||||
print("First 50 Duffinian numbers:");
|
||||
count = 0; n = 2;
|
||||
while(count < 50,
|
||||
if (isDuffinian(n),
|
||||
print1(n, " ");
|
||||
count++;
|
||||
);
|
||||
n++;
|
||||
);
|
||||
|
||||
print("\n\nFifteen Duffinian triplets:");
|
||||
count = 0; n = 2;
|
||||
while (count < 15,
|
||||
if (isDuffinian(n) && isDuffinian(n + 1) && isDuffinian(n + 2),
|
||||
print(n, " ", n + 1, " ", n + 2);
|
||||
count++;
|
||||
);
|
||||
n++;
|
||||
);
|
||||
}
|
||||
|
||||
testDuffinians();
|
||||
Loading…
Add table
Add a link
Reference in a new issue