در خواست کد ممنوعه ولی این می شه به سی


#include <stdio.h>

void PrimeFactors (int );


int main()
{
int n = 0;
printf("\t\tWelcome to Prime Factors program\n\n");
printf("Enter the number : ");
scanf("%d",&n);
printf("\n\n");
PrimeFactors(n);

return 0;
}

void PrimeFactors (int n)
{

int count = 0;
int temp = 0;


for ( int i = 1 ; i <= n ; i++ )
{

int j = i - 1;

while ( j > 1 )
{
if ( i % j == 0 ) //Is PRIME
break;
else
j--;
}

if ( j == 1 )
{
if ( n % i == 0 )
{
printf("\n%d",i); //PRIME factor

if ( i > temp )
{ temp = i;
count++;
}
}
}


}
printf("\n\nNumber of prime factors of %d : %d\n\n",n,count);
printf("Greatest prime factor is %d \n\n",temp);
}