java - Display numbers from 1 to 100 without loops or conditions -


is there way print numbers 1 100 without using loops or conditions "if"? can using recursion again has if condition. there way without using "if" well? no repetitive print statements, or single print statement containing numbers 1 100.

a solution in java preferable.

pseudo code. uses array force exception after 100 elements caught , nothing.

function r(array a, int index){     a[index] = a[index-1]+1     print a[index]     r(a, index+1) }  try{     array a;     a.resize(101)     r(a, 1) }catch(outofboundsexception){ } 

edit
java code:

public void printto100(){     int[] array = new int[101];     try{         printtoarraylimit(array, 1);     }catch(arrayindexoutofboundsexception e){     } } public void printtoarraylimit(int[] array, int index){     array[index] = array[index-1]+1;     system.out.println(array[index]);     printtoarraylimit(array, index+1); } 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -