Dsa
Math
Easy
Longest Sequence of Primes
Given an integer N, find the longest contiguous sequence of prime numbers up to N. The output should be the sequence itself. If there are no primes up to N, output 'No primes found'.
Input Format:
- A single integer N (2 <= N <= 1000)
Output Format:
- A space-separated string of the prime numbers, or 'No primes found'.
Example:
Input:
10
Output:
2 3 5 7
Key concepts
mathprimes
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now