C program to Find Prime Factors of any number without using single loop (based on recursion)

This  code for programming lover to find Prime factor without using single loop this code based only on recursion if you face any difficulty to understand this code please comment below thank you.

----------------------------------------------------------------------------------------------------


#include <stdio.h>

int l=1,z=1;
int pm(int x);
int num(int n)
                        {
                                if(n>1) {
                                                 num(n-1);
                                                      pm(n);
                                                                   }
                                                                        }

int pm(int x ) {

      if(l%x==0)  {
                              if(z==2)printf("*");
                                 printf(" %d ",x);
                                                    z=2;
                                                   l=l/x;
                                                     pm(x);
                                                                   }   }
int main()
                {     int x,y;

                        printf("Enter any Number : ");
                        scanf("%d",&x);
                         l=x;

                      num(x/2);
                         printf(" = %d\n\n",x);
                                     }

-----------------------------------------------------------------------------------------------------

0 Comments