Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int x;
- scanf("%d",&x);
- printf("%d=",x);
- bool print = 0;
- int num;
- int limit = static_cast<int>(sqrt(x));
- for( int i = 2; i <= limit; i++ ){
- num = 0;
- while( x % i == 0 ){
- num++;
- x /= i;
- }
- if( num )
- if( print ){
- printf( "*%d", i );
- if( num != 1 ) printf( "^%d", num );
- }
- else{
- print = 1;
- printf( "%d", i );
- if( num != 1 ) printf( "^%d", num );
- }
- }
- if( x != 1 )
- if( print )
- printf( "*%d", x );
- else
- printf( "%d", x );
- puts("");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement