Alx09

Untitled

Oct 14th, 2019
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. unsigned n;
  5.  
  6. void print(unsigned b, unsigned pow){
  7. if (pow != 1) printf("%u^%u * ", b, pow);
  8. else printf("%u.", b, pow);
  9. }
  10.  
  11. unsigned power(unsigned j){
  12.  
  13. if( n % j == 0) {
  14. n /= j;
  15. return 1 + power(j);
  16. }
  17. return 0;
  18. }
  19. void base(){
  20. unsigned i = 2;
  21. for (; i <= n/2; i++)
  22. if( n % i == 0) print(i, power(i));
  23.  
  24. }
  25. int main() {
  26.  
  27. printf("n= "); scanf("%u", &n);
  28. system("CLS");
  29. printf("%u = ", n);
  30. base();
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment