Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
33
Task/Arithmetic-numbers/SETL/arithmetic-numbers.setl
Normal file
33
Task/Arithmetic-numbers/SETL/arithmetic-numbers.setl
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
program arithmetic_numbers;
|
||||
[divsum, divcount] := calcdivsums(130000);
|
||||
|
||||
print("First 100 arithmetic numbers:");
|
||||
|
||||
loop for nth in [1..100000] do
|
||||
loop until divsum(num) mod divcount(num) = 0 do num +:= 1; end loop;
|
||||
comp +:= if num>1 and divsum(num) /= num+1 then 1 else 0 end if;
|
||||
|
||||
if nth <= 100 then
|
||||
putchar(rpad(str num, 5));
|
||||
if nth mod 10 = 0 then print(); end if;
|
||||
end if;
|
||||
|
||||
if nth in [1000, 10000, 100000] then
|
||||
print("The " + nth + "th arithmetic number is " + num + ".");
|
||||
print("Of the first " + nth + " arithmetic numbers, " +
|
||||
comp + " are composite.");
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
proc calcdivsums(m);
|
||||
sums := [];
|
||||
counts := [];
|
||||
loop for d in [1..m] do
|
||||
loop for n in [d, d*2..m] do
|
||||
sums(n) +:= d;
|
||||
counts(n) +:= 1;
|
||||
end loop;
|
||||
end loop;
|
||||
return [sums, counts];
|
||||
end proc;
|
||||
end program;
|
||||
Loading…
Add table
Add a link
Reference in a new issue