Category: divisors

Height of Factor Tree for a given number

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

Continue Reading

Count the divisors or multiples present in the Array for each element

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

Continue Reading

Sum of all the prime divisors of a number | Set 2

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

Continue Reading