Silent Infotech Interview Question

Write 1 to 100 without using any loop

Interview Answer

Anonymous

Sep 9, 2025

class Main { public static void main(String[] args) { print(1); } static void print(int n) { if (n > 100) return; System.out.println(n); print(n + 1); }