Search This Blog

Translate

c code for prime number,c program to find prime factors of a number using function

c code for prime number,c program to check given number is prime or not, check number prime or not c program, c source code to find number is prime or not,c program to find prime factors of a number using function,

 c program to find prime factors of a number using recursion



#include
#include
void factor(int);
void prime(int);
main()
{
 int n;
 clrscr();
 printf("Enter the number:");
 scanf("%d",&n);
 factor(n);
 getch();
}
void factor(int n)
{
 int i;
 for(i=2;i<=n-1;i++)
 {
   if(n%i==0)
    prime(i);
 }
}
void prime(int n)
{
 int i,flag=1;
  for(i=2;i<=n-1;i++)
  {
   if(n%i==0)
    {
     flag=0;
    }
  }
  if(flag==1)
  {
   printf("\n%d",n);
  }
}











c code for prime number,c program to check given number is prime or not, check number prime or not c program, c source code to find number is prime or not,c program to find prime factors of a number using function,


C Program example List

Google+ Badge