import java.io.*;import java.util.*; class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); ArrayList arrayList = new ArrayList(); int n = Integer.parseInt(in.readLine()); for(int a=2; a
import java.io.*;import java.util.*; class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); int result = 1; while(n != 0) { result *= n; n--; } System.out.println(result); }} 간단. 10! = 3628800 이므로 시간복잡도가 계승으로 나올 때는 답이 없다는 것을 알 수 있다. var n = Int(readLine()!)!var res..
import java.io.*;import java.util.*; class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); for(int i=2; i*i 1) { System.out.println(n); } }} 소인수분해를 위해 소수를 구할 필요 없이 2부터 sqrt(n)까지 순회하면서 해당 수가 주어진 수를 나눌 수 없을 때까지 나눠준다.끝에 남은 숫자를 출력하여 끝을 낸다. import Foundation var n = In..