Skip to content

Instantly share code, notes, and snippets.

@Eugleo
Last active January 1, 2019 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Eugleo/f32abbfd5a16188215aacf968c7f19a6 to your computer and use it in GitHub Desktop.
Save Eugleo/f32abbfd5a16188215aacf968c7f19a6 to your computer and use it in GitHub Desktop.
Najdi perfektní čísla, čtverce a krychle
program perfetto;
var
i, n, sum: Integer;
sqr, cube: Boolean;
begin
read(n);
sum := 1;
for i := 2 to (n div 2) do begin
if n mod i = 0 then
sum := i + sum;
if i * i = n then
sqr := True;
if i * i * i = n then
cube := True;
end;
if sum = n then
write('P');
if sqr then
write('C');
if cube then
write('K');
end.

program perfetto;

var i, n, sum: Integer; sqr, cube: Boolean;

begin read(n); sum := 1;

for i := 2 to (n div 2) do begin if n mod i = 0 then sum := i + sum; if i * i = n then sqr := True; if i * i * i = n then cube := True; end;

if sum = n then write('P'); if sqr then write('C'); if cube then write('K'); end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment