Uguly number, pls help me to solve this question using c++ and flow chart too

You are provided a sequence of number. All numbers of that sequence is in increasing order (including 1) and whose only prime factors are 2, 3 or 5 (except 1). You need to find the nth number of that sequence.
Input Format

First line contains integer t which is number of test case. For each test case, it contains an integer n.
Constraints

1<=t<=100 1<=n<=10000
Output Format

Print nth number of that sequence.
Sample Input

2
7
10

Sample Output

8
12

Explanation

Sequence : 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, ……

hello @Kash-Moulik-3715574511847721

r u familiar with dynamic programming?

no I’M not familiar with dynamic programming

ok then go with simple logic.

Loop for all positive integers until ugly number count is smaller than n, if an integer is ugly than increment ugly number count.

To check if a number is ugly, divide the number by greatest divisible powers of 2, 3 and 5, if the number becomes 1 then it is an ugly number otherwise not.

For example, let us see how to check for 300 is ugly or not. Greatest divisible power of 2 is 4, after dividing 300 by 4 we get 75. Greatest divisible power of 3 is 3, after dividing 75 by 3 we get 25. Greatest divisible power of 5 is 25, after dividing 25 by 25 we get 1. Since we get 1 finally, 300 is ugly number.

can u give a cpp solution

programming solution ?

@Kash-Moulik-3715574511847721
check this->

// CPP program to find nth ugly number 
# include<stdio.h> 
# include<stdlib.h> 
  
/*This function divides a by greatest divisible  
  power of b*/
int maxDivide(int a, int b) 
{ 
  while (a%b == 0) 
   a = a/b;  
  return a; 
}     
  
/* Function to check if a number is ugly or not */
int isUgly(int no) 
{ 
  no = maxDivide(no, 2); 
  no = maxDivide(no, 3); 
  no = maxDivide(no, 5); 
    
  return (no == 1)? 1 : 0; 
}     
  
/* Function to get the nth ugly number*/
int getNthUglyNo(int n) 
{ 
  int i = 1;  
  int count = 1;   /* ugly number count */ 
  
  /*Check for all integers untill ugly count  
    becomes n*/ 
  while (n > count) 
  { 
    i++;       
    if (isUgly(i)) 
      count++;  
  } 
  return i; 
} 
  
/* Driver program to test above functions */
int main() 
{ 
    unsigned no = getNthUglyNo(150); 
    printf("150th ugly no. is %d ",  no); 

    return 0; 
}