백준

백준 11653번 문제 소인수분해 (Java)

gxxgsta 2021. 7. 14. 22:12
반응형
SMALL
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub\
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		for(int i=2; i<N; i++) {
			while(N%i==0) {
				System.out.println(i);
				N /= i;
			}
		}
		if(N!=1) { System.out.println(N); }

	}

}
반응형
LIST