- #1
aleee
- 17
- 0
i need help making a program that only displays the prime factors
ex: 100 = 2*2*5*5
i got the program to display all the factors but after that I am lost.
here is the code so far
oh its in C++
#include <iostream>
using namespace std;
int main()
{
cout << "Enter a number: ";
int num;
cin >> num;
int i,k = 0;
for (int i=2; i <= num; i++)
{
if( num % i == 0)
{
if(num % i == 0)
{
k = num / i;
}
cout << i << " " << k << endl;
}
}
return 0;
}
ex: 100 = 2*2*5*5
i got the program to display all the factors but after that I am lost.
here is the code so far
oh its in C++
#include <iostream>
using namespace std;
int main()
{
cout << "Enter a number: ";
int num;
cin >> num;
int i,k = 0;
for (int i=2; i <= num; i++)
{
if( num % i == 0)
{
if(num % i == 0)
{
k = num / i;
}
cout << i << " " << k << endl;
}
}
return 0;
}