Comment on Tutorial - Recursion in java By aathishankaran



Comment Added by : Soph

Comment Added at : 2013-02-06 06:11:39

Comment on Tutorial : Recursion in java By aathishankaran
Declaring int result within the method will change the value of result each time you run the method, there is an alternative method :

class Factorial {

int fact(int n)
{
if ( n ==1) return 1;
return n* fact (n-1);
}
}

therefore taking the additional variable 'result' was completely unnecessary. Im in the twelfth grade.


View Tutorial



Ask a Question

Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. what ll be result for s1==s2 and s1.equals(s2) for
View Tutorial          By: vijay at 2011-08-21 15:09:41

2. Thanks to the author, it was really a good tutoria
View Tutorial          By: Ashok Kumar at 2010-04-29 05:54:47

3. The basic structure of simple program is used to l
View Tutorial          By: Muthusasi at 2009-12-17 21:10:01

4. it 's great
View Tutorial          By: tanawat bhtk at 2008-03-19 22:17:53

5. I'm trying to follow this backward, but I can't fi
View Tutorial          By: DMM at 2014-03-14 21:42:06

6. fitst read fully and put comments
View Tutorial          By: prasant at 2009-10-07 06:16:19

7. i am getting following error

Error

View Tutorial          By: Pavan at 2009-11-26 21:31:22

8. "I get an error returned saying the SMPT serv
View Tutorial          By: Dennis at 2011-06-24 10:18:10

9. Thank you, Every thing is working fine...!!

View Tutorial          By: Purushothaman at 2009-04-10 07:18:38

10. Its nice and really apriciate rakesh sir i try t
View Tutorial          By: prince at 2013-04-18 09:46:34