Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int i, j, num, isPrime;
- cout<<"Enter Number: "<<endl;
- cin>>num;
- cout<<"Prime factors of "<<num<<" are: "<<endl;
- for(i=2; i<=num; i++)
- {
- if(num%i==0)
- {
- isPrime = 1;
- for(j=2; j<=i/2; j++)
- {
- if(i%j==0)
- {
- isPrime = 0;
- break;
- }
- }
- if(isPrime==1)
- {
- cout<<i<<endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement