Más contenido relacionado
Más de LINE Corporation (20)
ググってOK!?LINEエンジニアの選考基準を全公開〜 開発職編 〜
- 10. 解答例1 ふつう
int count(int n) {
int total = 0;
for (int i = 1; i <= n; ++i) {
if (i % 5 == 0) {
continue;
}
total += i;
}
return total;
}
- 11. 解答例2 まじめ
int count(String arg) {
// 空白チェック
if (arg.isBlank()) {
throw new RuntimeException("値が入力されていません");
}
int n;
// 数値かどうか
try {
n = Integer.parseInt(arg);
} catch (NumberFormatException ex) {
throw new RuntimeException("数値を入力してください");
}
// 範囲チェック
if (n < 1) {
throw new RuntimeException("1以上を入力してください");