import java.util.ArrayList;
import java.util.List;
class Solution {
final int BLOCK_LIMIT = 10_000_000;
public Integer[] solution(long begin, long end) {
List<Integer> answerList = new ArrayList<Integer>(10000);
for (int value = (int) begin; value <= end; value++) {
if (value == 1) {
answerList.add(0);
} else {
int gcd = getGcd(value);
answerList.add(gcd);
}
}
return answerList.toArray(new Integer[0]);
}
private int getGcd(int value) {
for (int i = 2; i <= Math.sqrt(value); i++) {
if (value % i == 0) {
int divideValue = value / i;
if (divideValue <= BLOCK_LIMIT) {
return divideValue;
}
}
}
return 1;
}
}