Problem
A positive integer is entered through the keyboard. Write a function to obtain the prime factors of this number.Solution - Code
#include<stdio.h>#include<conio.h>
#include<stdlib.h>
void pr_fact();
main()
{
pr_fact();
system("pause");
}
void pr_fact()
{
int x,y,i;
printf("Enter any integer number : ");
scanf("%d",&x);
printf("Prime factors of %d : \n",x);
i = 1;
while( i <= x )
{
if ( x%i==0 )
printf("%d\n",i);
i++;
}
}
This comment has been removed by the author.
ReplyDelete