Wednesday, 1 Dec 2021
Category: divisors

Given a positive integer N, the task is to find the height of the Factor Tree of the given integer N.Examples:Input: N = 20Output: 3Explaination: The height of the Factor Tree of 20 shown in the image below is 3. Input: N = 48Output: 5Approach: The given problem can be solved by using the steps […]

function max_element(A, N) {            let MAX = Number.MIN_VALUE;            for (let i = 0; i < A.length; i++) {                if (A[i] > MAX) {                    MAX = A[i];                }            }            return MAX;        }        function countIndex(A, N) {                        let MAX = max_element(A, A + N);                                    let freq = new Array(MAX + 1).fill(0);            for (let i = 0; i < N; i++)                freq[A[i]]++;                                    let res = new Array(MAX + 1).fill(0);            for (let i = […]

Sum of all the prime divisors of a number | Set 2 Given a number N, the task is to find the sum of all the prime factors of N. Examples:Input: 10Output: 7Explanation: 2, 5 are prime divisors of 10Input: 20Output: 7Explanation: 2, 5 are prime divisors of 20Approach: This problem can be solved by finding […]

Print all numbers that are divisors of N and are co-prime with the quotient of their divisionGiven a positive integer N, the task is to print all the numbers, say K, such that K is a divisor of N and K and N / K are coprime.Examples:Input: N = 12  Output: 1 3 4 12 […]

Count pair sums that are factors of the sum of the arrayGiven an array arr[] consisting of N integers, the task is to find the number of pairs, where i ≤ j, such that the sum of pairs divides the sum of array elements.Examples:Input: arr[] = {1, 2, 3, 4, 5}Output: 3Explanation:Below are the pairs […]

Generate an array having sum of Euler Totient Function of all elements equal to N Given a positive integer N, the task is to generate an array such that the sum of Euler Totient Function of each element is equal to N. Examples: Input: N = 6Output: 3 8Explanation:The total number of integers i, from […]

Sum of quotients of division of N by powers of K not exceeding N Given two positive integers N and K, the task is to find the sum of the quotients of division of N by powers of K which are less than or equal to N. Examples: Input: N = 10, K = 2Output: […]

Check if a given number N has at least one odd divisor not exceeding N – 1 Given a positive integer N, the task is to check if the given number N has at least 1 odd divisor from the range [2, N – 1] or not. If found to be true, then print “Yes”. […]