Tutorialspoint.dev
Welcome To Tutorialspoint.dev
Officially launched 18th May 2019
Mathematical prime-factor sieve

Prime Factorization using Sieve O(log n) for multiple queries

We can calculate the prime factorization of a number “n” in O(sqrt(n)) as discussed here. But O(sqrt n) method times out when we need to answer multiple...
Dynamic Programming Mathematical GE

Sieve of Eratosthenes

Given a number n, print all primes smaller than or equal to n. It is also given that n is a small number. Example: Input : n =10 Output : 2 3 5 7 Input : n = 20 ...
Mathematical Prime Number sieve

Sieve of Sundaram to print all primes smaller than n

Given a number n, print all primes smaller than or equal to n. Examples: Input: n = 10 Output: 2, 3, 5, 7 Input: n = 20 Output: 2, 3, 5, 7, 11, 13, 17, 19 We have ...
Mathematical Prime Number sieve

Segmented Sieve

Given a number n, print all primes smaller than n. For example, if the given number is 10, output 2, 3, 5, 7. Recom...
Mathematical sieve Mathematical

Sieve of Eratosthenes in 0(n) time complexity

The classical Sieve of Eratosthenes algorithm takes O(N log (log N)) time to find all prime numbers less than N. In this article, a modified Sieve is discussed that w...
Mathematical Prime Number sieve

Sieve of Atkin

Given a limit, print all primes smaller than or equal to the given limit. Examples : Input: limit = 10 Output: 2, 3, 5, 7 Input: limit = 20 Output: 2, 3, 5, 7, 11...

Subscribe to Our Newsletter