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. Splendid! Haven\'t used asserts before, very helpf
View Tutorial          By: Anonymous at 2009-03-11 04:18:42

2. EJB's can be deployed on multiple servers and when
View Tutorial          By: Tomek at 2011-09-12 12:29:07

3. you really dont know how much i want to thank u...
View Tutorial          By: Angana Sengupta at 2013-01-23 18:34:51

4. sir , i'm doing BCA . I want to learn more about
View Tutorial          By: gayatri patil at 2012-08-18 10:08:32

5. please explain importance of java and explain it's
View Tutorial          By: sandhi.vijayanth reddy at 2012-10-01 16:30:54

6. I need code for read write mifare 1k card using No
View Tutorial          By: amarendra at 2010-12-02 21:12:08

7. Unsigned nature of variables
View Tutorial          By: Ganesh Chowdhari at 2008-08-12 06:33:12

8. thanks becase i am very confuse what is work how t
View Tutorial          By: arvind at 2011-01-09 14:41:42

9. thanks. it helped a lot!
View Tutorial          By: lateforbus at 2013-04-25 03:35:24

10. @Palla Subramanyam : Your logic is correct, but SO
View Tutorial          By: Roopesh H at 2012-07-27 04:47:48