Monday, March 28, 2022

Factorial a Number Using Recursion in Java

 A program that will ask the user to give a number and then the program will compute the factorial value of the given number using a recursion algorithm using Java programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg


=================================================

Want to support my the channel?


GCash Account


Jake Pomperada

09173084360


Paypal

https://paypal.me/jakerpomperada


Patreon

https://www.patreon.com/jakerpomperada


Thank you very much for your support





Program Listing

import java.util.*;

public class Factorial {

public static void main(String args[])
{
    int num;
Scanner input  = new Scanner(System.in);
   System.out.println("\n");
        System.out.print("\tFactorial a Number Using Recursion in Java");
        System.out.println("\n");
    System.out.print("\tGive a Number : ");
    num=input.nextInt();
        System.out.println();
    System.out.println("\tThe factorial("+num+") = "+factorial_recursion(num)+"\n");
    System.out.print("\tEnd of Program");
        System.out.println("\n");

    input.close();
   
}

static int factorial_recursion(int n)
{
    if(n==0)
        return 1;
    else
        return n*factorial_recursion(n-1);
}
}


No comments:

Post a Comment