QualityAI interview question

Print number 1 to 10 without using loops

Interview Answers

Anonymous

24 May 2017

recursive(int n) { if(n <= 10) { sop(n); recursive(n+1); } }

2

Anonymous

16 Oct 2019

public static void printWithoutLoop(int n) { if (n <= 10) { System.out.println(n); printWithoutLoop(n + 1); }