Created
July 18, 2013 02:42
-
-
Save danhper/6026317 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void) | |
{ | |
int a, i = 2; | |
printf("enter num: "); | |
scanf("%d", &a); | |
printf("%d = ", a); | |
while(a > 1) { | |
int n = 0; | |
while(a % i != 0) { | |
i++; | |
} | |
while(a % i == 0) { | |
a /= i; | |
n++; | |
} | |
if(n > 1) { | |
printf("%d^%d", i, n); | |
} else { | |
printf("%d", i, n); | |
} | |
if(a > 1) { | |
printf(" x "); | |
} | |
} | |
printf("\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment