What will be the result when you run this class?
For clarification, the language used is Java.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
In Java, division with integers will automatically round down to a int, so 1/a will be 0 if a>1. Math.random() returns a double that is greater than or equal to 0 and less than 1. In this class the base case is always true, so it will leave the recursive method before it can output anything, therefore there is no output.