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 […]