# Tag Archives: sieve

## Efficient program to print the number of factors of n numbers

Given an array of integers. We are required to write a program to print the number of factors of every element of the given array.… Read More »

## Prime Number of Set Bits in Binary Representation

Given two integers ‘L’ and ‘R’, we need to write a program that finds the count of numbers having prime number of set bits in… Read More »

## Total number of divisors for a given number

Given a positive integer n, we have to find the total number of divisors for n. Examples: Input : n = 25 Output : 3… Read More »

## Maximum number of unique prime factors

Given a number N, find the maximum number of unique prime factors any number can have in range [1, N]. Examples: Input : N =… Read More »

## Program to find sum of prime numbers between 1 to n

Write a C program to find sum of all prime numbers between 1 to n. Examples: Input : 10 Output : 17 Explanation : Primes… Read More »

## Sum of all proper divisors of natural numbers in an array

Given an array of natural numbers count the sum of its proper divisors for every element in array. Input : int arr[] = {8, 13,… Read More »

## Numbers with exactly 3 divisors

Given a number N, print all numbers in range from 1 to N having exactly 3 divisors. Input : N = 16 Output : 4… Read More »

## Count of subarrays whose products don’t have any repeating prime factor

Given an array of integers. Find the total number of subarrays whose product of all elements doesn’t contain repeating prime factor in prime decomposition of… Read More »

## Optimized Euler Totient Function for Multiple Evaluations

Euler Totient Function (ETF) Φ(n) for an input n is count of numbers in {1, 2, 3, …, n} that are relatively prime to n,… Read More »

## Find numbers with n-divisors in a given range

Given three integers a, b, n .Your task is to print number of numbers between a and b including them also which have n-divisors. A… Read More »

## Print prime numbers in a given range using C++ STL

Generate all prime numbers between two given numbers. The task is to print prime numbers in that range. The Sieve of Eratosthenes is one of… Read More »

## Left-Truncatable Prime

A Left-truncatable prime is a prime which in a given base (say 10) does not contain 0 and which remains prime when the leading (“left”)… Read More »

## Nth Square free number

Given a number n, find the n-th square-free number. A number is square-free if it is not divisible by a perfect square other than 1.… Read More »

## Count pairs with sum as a prime number and less than n

Given a positive integer n, count distinct number of pairs (x, y) that satisfy following conditions : (x + y) is a prime number. (x… Read More »

## Count Divisors of n in O(n^1/3)

Given a number n, count all distinct divisors of it. Examples: Input : 18 Output : 6 Divisors of 18 are 1, 2, 3, 6,… Read More »