/*wap to find prime factors of a given positive int num(make function "factor" to find prime factor)*/ #include<stdio.h> #include<conio.h> void factor(int n); void main() { int n; clrscr(); printf("Enter any int to find its Prime Factors:\n"); scanf("%d",&n); factor(n); getch(); } void factor(int n) { int a,i,j,c=0; printf("prime factor\n"); for(i=2;i<=n;i++) { c=0; if(n%i==0) { a=i; for(j=2;j<i;j++) { if(a%j==0) {c++;} } if(c==0) {printf("%d\n",a);} } } }
wap to find prime factors of a given positive int number (make function "factor" to find prime factor)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment