Showing posts with label Find Prime Factor of number. Show all posts
Showing posts with label Find Prime Factor of number. Show all posts

Find Prime Factor of number


/*Program to find out prime factors of a given number.*/

#include<stdio.h>
#include<conio.h>

void main()
{
int number;
printf("Enter a number ");
scanf("%d",&number);
printf("\nThe prime factors of %d are:",number);
for(int num=2;num<32767;num++)
{
int i=2;
while(i<=num-1)
{
if(num%i==0)
{
break;
}
i++;
}
if(i==num)
{
if(number%num==0)
{
number=number/num;
printf("\t%d",num);
num=1;
}
else
{
continue;
}
}
}
getch();
clrscr();
}

Labels