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

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

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



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!


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