Created
December 30, 2019 08:35
-
-
Save thinkphp/76411e95071ee75dad612c736fce7953 to your computer and use it in GitHub Desktop.
Fundamental Theorem of Arithmetic.
This file contains 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(int argc, char const *argv[]) | |
{ | |
int n, fm, i; | |
printf("%s", "n="); | |
scanf("%d", &n); | |
i = 2; | |
do { | |
fm = 0; | |
while(n % i == 0) { | |
fm++; | |
n /= i; | |
} | |
if(fm!=0) printf("%d^%d + ", i, fm); | |
i++; | |
} while( n != 1); | |
printf("\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment