
Запиши программу на языке Паскаль. Определить, является ли число, введенное с клавиатуры простым.


Ответы на вопрос

begin
writeln('введите число');
readln(a);
c:=a;
for b:=1 to a do begin
if (c mod b=0) then prime:=prime+1;
end;
if (prime>2) then writeln('число не простое')
else writeln('число простое ');
end.



Program in Pascal to Determine if a Number is Prime
Sure, I can help you with that. Below is a simple program in Pascal to determine if a number entered from the keyboard is prime:
```pascal program CheckPrimeNumber; var num, i: integer; isPrime: boolean; begin isPrime := true; write('Enter a positive integer: '); readln(num); for i := 2 to num div 2 do begin if (num mod i) = 0 then begin isPrime := false; break; end; end; if isPrime then writeln(num, ' is a prime number') else writeln(num, ' is not a prime number'); end. ```
This program prompts the user to enter a positive integer and then checks whether the number is prime or not. It uses a simple loop to iterate through the numbers from 2 to half of the input number and checks for divisibility. If the number is found to be divisible by any number other than 1 and itself, it is not prime.
Note: This program assumes that the user will enter a positive integer.
I hope this helps! Let me know if you have further questions or need additional assistance.


Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili