fork download
  1. #include <stdio.h>
  2.  
  3. int main(int argc, char const *argv[]) {
  4.  
  5. //we declare the variable for our algorithm
  6. int n, //n input
  7. i, //start with a variable i
  8. fm;//multiplicity factor
  9.  
  10. printf("%s","Fundamental Theorem of Arithmentic\n");
  11. printf("%s\n","Source: https://m...content-available-to-author-only...m.com/FundamentalTheoremofArithmetic.html");
  12. printf("%s","Give a N = ");
  13. //read an integer
  14. scanf("%d", &n);
  15.  
  16. printf("%d = ", n);
  17. //start with i equal 2
  18. i = 2;
  19. do {
  20.  
  21. fm = 0;
  22.  
  23. while( (n % i) == 0) {
  24.  
  25. fm++;
  26.  
  27. n /= i;
  28. }
  29.  
  30. if(n == 1) printf("%d ^ %d", i, fm);
  31. else
  32. if( fm!=0 ) printf("%d ^ %d * ", i, fm);
  33.  
  34.  
  35. i++;
  36.  
  37. } while(!( n == 1 ));
  38. printf("\n");
  39.  
  40. return 0;
  41. }
  42.  
Success #stdin #stdout 0s 5284KB
stdin
100
stdout
Fundamental Theorem of Arithmentic
Source: https://m...content-available-to-author-only...m.com/FundamentalTheoremofArithmetic.html
Give a N = 100 = 2 ^ 2 * 5 ^ 2