Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- unsigned n;
- void print(unsigned b, unsigned pow){
- if (pow != 1) printf("%u^%u * ", b, pow);
- else printf("%u.", b, pow);
- }
- unsigned power(unsigned j){
- if( n % j == 0) {
- n /= j;
- return 1 + power(j);
- }
- return 0;
- }
- void base(){
- unsigned i = 2;
- for (; i <= n/2; i++)
- if( n % i == 0) print(i, power(i));
- }
- int main() {
- printf("n= "); scanf("%u", &n);
- system("CLS");
- printf("%u = ", n);
- base();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment