Write a program that takes an integer argument and return all the primes between 1 and the integer.
Answers
Answered by
0
Answer:
Given a number N, the task is to print the prime numbers from 1 to N.
Examples:
Input: N = 10
Output: 2, 3, 5, 7
Input: N = 5
Output: 2, 3, 5 Approach:
First, take the number N as input.
Then use a for loop to iterate the numbers from 1 to N
Then check for each number to be a prime number. If it is a prime number, print it.
Explanation:
Similar questions