Skip to content

Instantly share code, notes, and snippets.

@thinkphp thinkphp/fta.c
Created Dec 30, 2019

Embed
What would you like to do?
Fundamental Theorem of Arithmetic.
#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
You can’t perform that action at this time.