Вопрос задан 06.05.2019 в 17:28. Предмет Информатика. Спрашивает Копылова Софья.

Дано натуральное число N,составить программу,котоая выводит на экран все натуральные числа,квадрат

которых не больше чем N
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Ёлкин Дима.
Var n,i:integer;
begin
write('n = ');
readln(n);
i:=1;
while i*i<=n do
 begin
 write(i,' ');
 i:=i+1;
 end;
writeln;
end.

Пример:
n = 30
1 2 3 4 5 
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Program to Print Natural Numbers Whose Square is Less Than or Equal to N

Here is a program in Python that prints all the natural numbers whose square is less than or equal to a given number N:

```python def print_numbers(N): i = 1 while i * i <= N: print(i) i += 1

# Example usage N = 25 print_numbers(N) ```

This program defines a function `print_numbers` that takes a parameter `N`. It initializes a variable `i` to 1 and enters a while loop. The loop condition checks if the square of `i` is less than or equal to `N`. If it is, it prints the value of `i` and increments `i` by 1. The loop continues until the square of `i` exceeds `N`.

In the example usage, `N` is set to 25, so the program will print all the natural numbers from 1 to 5, as their squares are less than or equal to 25.

Please note that this program assumes that `N` is a positive integer. If `N` is not a positive integer, the program may produce unexpected results.

Let me know if you have any further questions!

0 0

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос