View Code of Problem 91

#include <stdio.h>
 
int is(int i){
	int ret=1;
	int j ;
	for(j=2; j<i; j++){
		if(i%j == 0){
			ret = 0;
			break;
		}
	}
	return ret;
} 
 
int main(){
	int x;
	int n=1;
	int i;
	scanf("%d",&x);
	printf("%d=",x);
	if(is(x)){
		printf("%d",x);
	}
	else{
		while(x != 1){
			for(i=2 ; i<=x ; i++){
			if(is(i) && x%i == 0){
					printf("%d",i);
					if(i != x ){
						printf("*");
						}
					x = x/i;
					i = 1; 
				}
			}
		
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 91