Tag Archives: prime-factor

Total number of divisors for a given numberSeptember 10, 2017

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 factorsSeptember 9, 2017

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 »

Find minimum sum of factors of numberAugust 8, 2017

Given a number, find minimum sum of its factors. Examples: Input : 12 Output : 7 Explanation: Following are different ways to factorize 12 and… Read More »

Factor Tree of a given NumberJuly 17, 2017

Factor Tree is an intuitive method to understand factors of a number. It shows how all the factors are been derived from the number. It… Read More »

Sum of all proper divisors of natural numbers in an arrayJuly 11, 2017

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 divisorsJuly 6, 2017

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 factorJuly 4, 2017

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 »

Smallest number S such that N is a factor of S factorial or S!June 20, 2017

Given a number N. You are tasked with finding the smallest number S, such that N is a factor of S! (S factorial). N can… Read More »

Find if n can be written as product of k numbersApril 17, 2017

Given a positive number n, we need to print exactly k positive numbers (all greater than 1) such that product of those k numbers is… Read More »

Check if the door is open or closedApril 8, 2017

Given n doors and n persons. The doors are numbered 1 to n and persons are given id’s numbered 1 to n. Each door can… Read More »

Find politeness of a numberMarch 24, 2017

Given an integer n. Find politeness of number n. Politeness of a number is defined as the number of ways it can be expressed as… Read More »

Prime Factorization using Sieve O(log n) for multiple queriesMarch 10, 2017

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 factorMarch 7, 2017

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 »

Largest subsequence having GCD greater than 1March 3, 2017

Given an array arr[], find the largest subsequence such that GCD of all those subsequence are greater than 1. For exampple:- Input: 3, 6, 2,… Read More »