diff --git a/profiles/BHUPENDRArocxx.md b/profiles/BHUPENDRArocxx.md new file mode 100644 index 0000000000..e94c32ed47 --- /dev/null +++ b/profiles/BHUPENDRArocxx.md @@ -0,0 +1,15 @@ +# BHUPENDRArocxx +### Location +India +### Academics +ARMY INSTITUTE OF TECHNOLOGY , PUNE +AUTOMATION AND ROBOTICS ENGG. +### Interests +- Web Development (React, JavaScript) +- Game Development +- Algorithms +### Projects +- [Games Hub Contribution](https://github.com/BHUPENDRArocxx/Games-Hub-HacktoberFest-2025) Simple mini-games created with React. +- [Hacktober 2025 Algorithms](https://github.com/BHUPENDRArocxx/hbtuHacktoberfest2025) Collection of algorithms and utilities. +### Profile Link +[BHUPENDRArocxx](https://github.com/BHUPENDRArocxx) \ No newline at end of file diff --git a/scripts/factorial_recursive_BHUPENDRArocxx.java b/scripts/factorial_recursive_BHUPENDRArocxx.java new file mode 100644 index 0000000000..0df4bc0ebd --- /dev/null +++ b/scripts/factorial_recursive_BHUPENDRArocxx.java @@ -0,0 +1,29 @@ +// LANGUAGE: Java +// ENV: JDK +// AUTHOR: BHUPENDRArocxx +// GITHUB: https://github.com/BHUPENDRArocxx + +class Factorial { + public static long calculateFactorial(int n) { + if (n < 0) { + return -1; // Factorial not defined for negative numbers + } + // Base case: factorial of 0 or 1 is 1 + if (n == 0 || n == 1) { + return 1; + } + // Recursive step + return n * calculateFactorial(n - 1); + } + + public static void main(String[] args) { + int number = 5; + long result = calculateFactorial(number); + + if (result != -1) { + System.out.println("Factorial of " + number + " is: " + result); + } else { + System.out.println("Invalid input."); + } + } +} \ No newline at end of file