# Tag Archives: sieve

## Count all perfect divisors of a number

Given a number n, count total perfect divisors of n. Perfect divisors are those divisors which are square of some integer. For example a perfect… Read More »

## 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… Read More »

## Nearest element with at-least one common prime factor

Given an array arr[], find nearest element for every element such that there is at least one common prime factor. In output, we need to… Read More »

## Number with maximum number of prime factors

Given an integer N. The task is to find a number that is smaller than or equal to N and has maximum prime factors. In… Read More »

## Queries on the sum of prime factor counts in a range

There are Q queries. Each query is of the form of L and R. The task is to output sum of number of prime factors… Read More »

## Minimum operations required to remove an array

Given an array of N integers where N is even. There are two kinds of operations allowed on the array. Increase the value of any… Read More »

## k-th prime factor of a given number

Given two numbers n and k, print k-th prime factor among all prime factors of n. For example, if the input number is 15 and… Read More »

## 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… Read More »

## Find two prime numbers with given sum

Given an even number (greater than 2 ), print two prime numbers whose sum will be equal to given number. There may be several combinations… Read More »

## Super Prime

Super-prime numbers (also known as higher order primes) are the subsequence of prime numbers that occupy prime-numbered positions within the sequence of all prime numbers.… Read More »

## Mersenne Prime

Mersenne Prime is a prime number that is one less than a power of two. In other words, any prime is Mersenne Prime if it… Read More »

## Find the highest occurring digit in prime numbers in a range

Given a range L to R, the task is to find the highest occurring digit in prime numbers lie between L and R (both inclusive).… Read More »

## Circular primes less than n

Find all circular primes less than given number n. A prime number is a Circular Prime Number if all of its possible rotations are itself… Read More »

## Sphenic Number

A Sphenic Number is a positive integer n which is product of exactly three distinct primes. The first few sphenic numbers are 30, 42, 66,… Read More »

## Equidigital Numbers

A number n is called Equidigital if the number of digits in the prime factorization of n (including powers) is same as number of digits… Read More »