Category: factor

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

Convert a number to another by dividing by its factor or removing first occurrence of a digit from an array

  #include using namespace std;  int isPresent(int n, int x){        string num = to_string(n);          for (int i = 0; i < num.size();         i++) {                          if ((num[i] - '0') == x)            return i;    }    return -1;}  int removeDigit(int n, int index){        string num = to_string(n);          string ans = "";          for (int i = 0;         i < num.size(); i++) {        if (i != index)            ans += num[i];    }              if (ans == "" || (ans.size() == […]

Continue Reading