This is one of the interesting problems I have seen on coding interviews for beginners. The program has surprise element by saying that you need to Print 1 to 100 without using a Loop e.g. for, forEach or enhanced for loop. This brings out some innovative solutions from candidates which tell a lot about their approach, knowledge, and attitude. I remember, asking this question during campus recruitment to at least 5 candidates. The first one took 5 minutes to think and then come up with the brute force way where he just copies pasted 100 System.out.println() and printed number 1 to 100 but when we asked to improve that, he couldn't too that. Unfortunately, he didn't think that recursion can replace an iterative algorithm without using a loop.
Read more »This post first appeared on Javarevisited: Blog About Java Programmin, please read the originial post: here