C Program To Print Prime Factors of a Number Using Recursion - Prime Factorisation

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

void prime(int num)
{
int i=2;

if(num==1)
return;

while(num%i!=0)
++i;

printf("%d ",i);

prime(num/i);

}

void main()
{
int num;
clrscr();
printf("Enter Any Number  :  ");
scanf("%d",&num);

printf("\n\nPrime Factors  %d = ",num);
prime(num);

getch();

}
Share on Google Plus

About Akash Manhas

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment