What's new

Closed Getting prime factors

Status
Not open for further replies.

ken21

Addict
Joined
Feb 19, 2016
Posts
9
Reaction
2
Points
65
#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int i,num;

printf("Enter number:");
scanf("%d",&num);

printf("\nAll prime factors of %d are: ",num);

i=2;

while(num!=0){
if(num%i!=0)
i=i+1;
else{
num=num/i;
printf("\t%d",i);
if(num==1)
break;
}
}
getch();
}
 
Status
Not open for further replies.

Similar threads

Back
Top