Thursday, June 9, 2016

Factorial Program in Java using recursion

Hi Folks , Today I am going to talk about the factorial program of 'n' numbers in java , how to implement it and what is the time complexity all other things , in my earlier post I have talked about Tower of Hanoi problem 
You can also see other Sorting program
Bubble Sort 
Selection Sort
Insertion Sort 


IMPLEMENTATION OF FACTORIAL 


public class FactorialRecursion {
// main method
public static void main(String[] args) {

System.out.println(factorial(5)); // need to find the factorial of 5
}

public static  int factorial(int i)
{
if(i==0) return 1;
else 
return i*factorial(i-1);
}


}


OUTPUT -   120

Time Complexity - The Time Complexity of Factorial Function is O(n).

Guys if you have any problem regarding the code  and any suggestion , please let me know. I will try to help / Improve.

Thank for reading

- Noeik


12 comments:

  1. Image


    Hi Admin, its an informative post, Java is most popular programming language and it offer huge career prospects for the talented professionals.
    J2EE Training in Chennai|JAVA Training Chennai|JAVA J2EE Training in Chennai

    ReplyDelete
  2. Image


    I love your blog, it is clear, concise, friendly and very helpful. I want to say thank you for sharing the right information!
    Richard Brown data room services

    ReplyDelete
  3. Image

    This comment has been removed by the author.

    ReplyDelete
  4. Image
  5. Image

    I learn so many things from your blog, thank you for updating such a wonderful post.. Java Training Institute in Chennai | Java Training Institute in Velachery.

    ReplyDelete
  6. Image
  7. Image
  8. Image

    It is the important idea for java apps code.Java is mostly created for web administration it's only using now OOPS concepts.You have a right information very beneficial article.If want become learn about for Java with Hadoop detailed if want become to learn about for Software Testing Training in Chennai , Software Testing Training Institute in Chennai

    ReplyDelete
  9. Image

    I like your blog You are developing some software like java it's useful from me me.keep updates.
    CCNP Training Institute in Chennai | CCNP Certification Training in Chennai | CCNP Routing Training in Chennai

    ReplyDelete
  10. Image

    Thanks for giving such a nice information about java concept. I gain some knowledge about java.Your way of explaining is very simple...
    No.1 Software Testing Training Institute in Chennai | Best Selenium Training Institute in Chennai | ISTQB Certification Center in Velachery

    ReplyDelete
  11. Image

    Your blog was explain everything in detailed manner and it was very interesting to read. Kindly keep updating such a nice blog.MCSE Training Institute in Chennai | MCSA Training Institute in Chennai | Hardware & Networking Training in Chennai

    ReplyDelete