Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
36
Task/Duffinian-numbers/PascalABC.NET/duffinian-numbers.pas
Normal file
36
Task/Duffinian-numbers/PascalABC.NET/duffinian-numbers.pas
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
uses school;
|
||||
|
||||
function is_duffinian(x: integer) :=
|
||||
(gcd(x, divisors(x).Sum) = 1) and
|
||||
(divisors(x).ToArray.Length > 2);
|
||||
|
||||
begin
|
||||
var count := 0;
|
||||
var i := 0;
|
||||
writeln('First 50 Duffinian numbers:');
|
||||
while count < 50 do
|
||||
begin
|
||||
if is_duffinian(i) then
|
||||
begin
|
||||
write(i:4);
|
||||
count += 1;
|
||||
if count mod 10 = 0 then writeln;
|
||||
end;
|
||||
i += 1
|
||||
end;
|
||||
|
||||
count := 0;
|
||||
i := 0;
|
||||
writeln;
|
||||
writeln('First 15 Duffinian triplets:');
|
||||
while count < 15 do
|
||||
begin
|
||||
if is_duffinian(i) and is_duffinian(i + 1) and is_duffinian(i + 2) then
|
||||
begin
|
||||
writeln(i:6, i + 1:6, i + 2:6);
|
||||
count += 1;
|
||||
i += 3;
|
||||
end;
|
||||
i += 1;
|
||||
end;
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue