All prime numbers
Given an integer N, print all the prime numbers that lie in the range 2 to N (both inclusive).
Print the prime numbers in different lines.
Input Format :
Integer N
Output Format :
Prime numbers in different lines
Constraints :
1 <= N <= 100
CodingNinjas
author
2y
You can solve this problem using brute force or sieve of eratosthenes. I solved it using sieve of eratosthenes
CodingNinjas
author
2y
Space Complexity: Explanation: Time Complexity: Explanation:
Gaurav Sharma
1y
step 1: Take a Boolean vector initialize all the position with true
step 2: Now iterate the outer loop from i=2 to sqrt of n
step 3: when u got arr[i]=true means this is a prime number so all the multip...read more
Add answer anonymously...
Top Indiamart Intermesh Associate Software Engineer interview questions & answers
Popular interview questions of Associate Software Engineer
Top HR questions asked in Indiamart Intermesh Associate Software Engineer
>
Indiamart Intermesh Associate Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app