Written by @Yusif_M and @Tuncay_Pashayev.
In this problem there is a number and we have to show number with the product of prime numbers.
First we have to find prime factors of this number, then we'll divide to prime factor while it is divisible to prime factor. When it is not divisible we'll move to next number and becuase we are dividing to prime factors while it divisible we won't face with the numbers which are not prime. At last we'll check if is greater than or not if it is greater then it means that it is divided to all possible prime numbers and remaining is prime and it can't be divided to any other prime number. This is the steps that we have to do to find prime factors of number .
vector <int> v;Creating a vector called .
for (int i = 2; i <= sqrt(n); i++)
{
while (n % i == 0)
{
v.push_back(i);
n /= i;
}
}Checking if number is divisible by any prime factor. If it is then add this number to vector. Their number can be more than , so adding all of them.
if (n > 1)
{
v.push_back(n);
}Checking if remaining number after divided by all prime numbers is bigger than , that means the remaining number is also one of prime factor of .
for (int i=0; i < v.size(); i++)
{
cout << v[i];
if (i < v.size()-1)
{
cout << "*";
}
}Printing all prime factors of by '*'. If is equals to v[v.size()-1], that means we mustn't output '*'.