Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Project Euler 21 - Amicable numbers
//fpc 3.0.0 // AMICABLE NUMBERS FINDER PROGRAM // Amicable numbers : Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). // If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers. program Project21; var s : int64; a : array[1..10000] of integer; i,j :integer; function sum(n:integer) : integer; var i:integer; begin sum:=0; for i:=1 to (n div 2) do if n mod i = 0 then sum:=sum + i; end; begin // Khi chay den 10000, may ton qua nhieu thoi gian (SIGNAL KILL). Ly do: goi chuong trinh con "sum" for i:=1 to 10000 do // den 2*10000^2 lan. De giam cong viec cho may, luu gia tri "sum" tuong ung cua so vao mang. Khi do a[i]:=sum(i); // so lan goi module "sum" chi con 10000. for i:=1 to 10000 do for j:=1 to 10000 do if (a[i]=j) and (a[j]=i) and (i<>j) then begin s:=s+i+j;writeln(i,' - ',j);end; s:=s div 2; write(s); end.
run
|
edit
|
history
|
help
0
zadanye 3 b
zad27-notoptimal
zadacha3
BubbleSor (slimst)
task 3
Урок 3, задача 5 Задача 1478. Урок в неделе
bbbrandomchar_0.1
program z1
[DE/GER] Vigenere Chiffre (Entschlüsselung)
Overflow error