Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <stdio.

h>
#include <stdbool.h>

int main()
{
bool isprime(int p);
int a;
scanf("%d",&a);
int i;
for(i = a;i>=1;i--)
{
if((a%i==0)&&(isprime(i)))
{
printf("%d\n",i);
}
}
}
bool isprime(int p)
{
if(p==1)
{
return false;
}
else
{
int j;
for(j=p-1;j>1;j--)
{
if(p%j==0)
return false;
}
return true;
}
}

You might also like