Program to find out the factors of given number(Level - Medium)

Program # 24: Program to find out factors of given number

//Program to find out the factors of given number(Level - Medium)
#include <iostream.h> 
#include <conio.h>

void main ()
{
clrscr();
int n,i,j,res;
cout<<"Enter any number = ";
cin >> n;

for(i=1;i<=20;i++)           
for(j=2;j<=i;j++)
if(n%j==0)
{
cout<<j<<endl; n = n/j;
}
getch ();
}


Post a Comment

0 Comments