allintitle:Reverse factorial program in java code example

Example: Reverse factorial program in java

// Reverse factorial program in java
import java.util.Scanner;
public class ReverseFactorialProgram
{
   public static void main(String[] args)
   {
      Scanner sc = new Scanner(System.in);
      System.out.println("Please enter a number to compute reverse factorial: ");
      int number = sc.nextInt();
      int reverse = number;
      for(int a = 2; reverse != a; a++)
      {
         reverse = reverse / a;
      }
      System.out.println("Reverse factorial of " + number + " is: " + reverse);
      sc.close();
   }
}

Tags:

Java Example