Skip to content

Instantly share code, notes, and snippets.

@gordinmitya
Created November 23, 2015 14:29
Show Gist options
  • Save gordinmitya/bfced24bf50df27da71f to your computer and use it in GitHub Desktop.
Save gordinmitya/bfced24bf50df27da71f to your computer and use it in GitHub Desktop.
Составить программу для проверки, можно ли заданное натуральное число N представить в виде квадрата простого числа.
var n, h: Integer;
function isPrime(n: INteger): Boolean;
var i: integer;
begin
isPrime:=true;
//for i:=2 to n-1 do - как тебе больше нравится
for i:=2 to trunc(sqrt(n)) do
if n mod i = 0 then
isPrime := false;
end;
begin
readln(n);
h:=trunc(sqrt(n));
if isPrime(h) and (h*h = n) then
write('can')
else
write('can not');
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment