Welcome Guest.

# Calculate and output all the positive factors of N as prime numbers. If not, output No Answer after returning to the main function.

Asked by: Gregory 228 views IT November 28, 2018

[Input form] Enter the integer N from the console.

[Output form] In the order from small to large, all the positive factors of N are output on one line, and each positive factor is separated by a space. If not, No Answer is output.

[Sample input]36

[Sample output] 2 3

[Sample input]1

[Example description] The input integer N is 36, and all positive factors of 36 are 1, 2, 3, 4, 6, and 9. 12, 18, 36, of which only 2 and 3 are prime numbers, so output 2

[Sample Description] If the test data is 11, output 11 is output. Note that it is also a prime number of factors.

C language, thank you

#include<stdio.h>
#include<math.h>
int sushu(int x)
{
int flag=0,j;
if(x= =2)
return 0;
for(j=2;j<sqrt(x)+1;j++)
{
if(x%j==0)
{
flag=1;
return 1;
}
}
if(flag==0)
return 0;
}

Program reference

#include <stdio.h>
int main(void)
{
int n, i,oldi=0, b = 0;
scanf("%d",&n);
if (n<2)
{
printf (" No Answer \ n ");
return 0;
}

for (i = 2; i < = n; i ++)
nbsp &; {
while (n% i == 0)
{
;   &nbsp         if (! oldi = i)
&nb sp;   {

&nbsp if (b == 0);                             {
b = 1;
}
else
printf (" ");
oldi = i;
;               &nbsp printf ("%d",i);
}
n / = i;
}

}
return 0;
}