The document outlines an algorithm to print all prime numbers within a user-defined range. It involves taking input for the start and end limits, checking each number for primality by testing divisibility from 2 to the square root of the number. If a number is determined to be prime, it is printed; the process continues for all numbers in the specified range.
The document outlines an algorithm to print all prime numbers within a user-defined range. It involves taking input for the start and end limits, checking each number for primality by testing divisibility from 2 to the square root of the number. If a number is determined to be prime, it is printed; the process continues for all numbers in the specified range.
Write an algorithm to print all prime numbers between two numbers (start and end) provided by the user.
Algorithm: Print Prime Numbers in a Range
1. Start
2. Take input from the user:
start → lower limit of range
end → upper limit of range
3. Loop through all numbers from start to end
4. For each number n :
If n is less than 2, skip it (since 1 and 0 are not prime)
Initialize a flag is_prime = True Check divisibility from 2 to sqrt(n) : If n is divisible by any number in this range, set is_prime = False and break the loop
5. If is_prime remains True , print the number n as prime