Created
November 23, 2015 14:29
-
-
Save gordinmitya/bfced24bf50df27da71f to your computer and use it in GitHub Desktop.
Составить программу для проверки, можно ли заданное натуральное число N представить в виде квадрата простого числа.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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