Find All Prime Numbers in Range (Sieve Method)

C++ Hard 2 views
Back to Questions

Problem Description

Find all prime numbers between 1 and N efficiently.
Real Life: Used in cryptography and security.

Step-by-Step Logic:
1. Create array marking all numbers as prime initially
2. Start from 2 (first prime)
3. Mark all multiples of 2 as not prime
4. Move to next unmarked number (next prime)
5. Repeat until all checked
6. Print all marked primes

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev