42 lines
714 B
C
42 lines
714 B
C
|
/*
|
|||
|
Program: prime-factoring-array.c (Report comments/bugs to chikh@yuntech.edu.tw)
|
|||
|
Function:
|
|||
|
*/
|
|||
|
|
|||
|
#include <stdio.h>
|
|||
|
|
|||
|
int indx = 0;
|
|||
|
int factor[100];
|
|||
|
|
|||
|
void divide(int n, int divisor)
|
|||
|
{
|
|||
|
if (divisor > n)
|
|||
|
return;
|
|||
|
else if (n%divisor != 0)
|
|||
|
divide(n,divisor+1);
|
|||
|
else {
|
|||
|
printf("%d ",factor[indx++] = divisor);
|
|||
|
divide(n/divisor,divisor);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
int main()
|
|||
|
{
|
|||
|
int i, j, n;
|
|||
|
|
|||
|
printf("<EFBFBD><EFBFBD><EFBFBD>J<EFBFBD><EFBFBD><EFBFBD>]<5D><><EFBFBD><EFBFBD><EFBFBD>Ѫ<EFBFBD><D1AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ==> ");
|
|||
|
scanf("%d",&n);
|
|||
|
printf("\n<EFBFBD><EFBFBD><EFBFBD>]<5D>Ƭ<EFBFBD><C6AC>G");
|
|||
|
divide(n,2);
|
|||
|
printf("\n\n%d = ",n);
|
|||
|
for (i = 0; i < indx;) {
|
|||
|
printf("%d",factor[i]);
|
|||
|
for (j = 1; i+j < indx; j++)
|
|||
|
if (factor[i+j] != factor[i]) break;
|
|||
|
if (j > 1) printf("^%d",j);
|
|||
|
if ((i=i+j) < indx) printf("<EFBFBD><EFBFBD>");
|
|||
|
}
|
|||
|
|
|||
|
return 0;
|
|||
|
}
|