View Code of Problem 91

#include <stdio.h>
#include <math.h>

int main(){
	int n;
	scanf("%d",&n);
	
	int i;
	int flag=0;	//控制第一个输出 
	printf("%d=",n);
	for(i=2;i<=n;){	//不要用i++,会出现漏了重复的素数 
		if(n%i==0){
			if(flag==0){
				printf("%d",i);		//第一个输出 数字 2 
				flag=1;
			}else{				//除了第一个 输出 *数字  *2*2 
				printf("*%d",i);
			}
			n=n/i;
		}else{
			i++;
		}
	}
	
	return 0;
	
}

Double click to view unformatted code.


Back to problem 91