import java.util.*;
/*
μκ°μ΄κ³Όκ° μκΎΈ λλκ±° 보λ μ΄λΆνμ? -> μλμλ€κ³ νλ€.
*/
class Solution {
public int[] solution(long begin, long end) {
int[] answer = new int[(int)(end-begin+1)];
int idx = 0;
for(long i = begin;i<=end;i++){
answer[idx++] = find(i);
}
return answer;
}
static int find(long num){
if(num == 1) return 0; //1μκ²½μ° 0리ν΄
int n = 2; //λλ μ. 2λΆν° λλλ€.
int div = 1;
while(n <= Math.sqrt(num)){
if(num%n == 0) { //μ½μλΌλ©΄
if(num/n<=10000000) return (int)num/n; //10λ§μ΄νμ μλΌλ©΄ 리ν΄
div = n;
}
n++;
}
return div;
}
}
μ²μμ μ§°λ μ½λλλ‘ νλ©΄ ν¨μ¨μ± ν μ€νΈμμ μκ°μ΄κ³Όκ° λ¬λ€.(κ·Όλ° μ½λλ₯Ό μ§μλ²λ €μ κΈ°λ‘μ λͺ»λ¨κΉ γ γ )
begin
λΆν°end
κΉμ§ κ°μ₯ μμ μ½μλ‘ λλμ΄μ§λ μλ₯Ό μ°Ύλλ€.
Β