Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions profiles/BHUPENDRArocxx.md
Original file line number Diff line number Diff line change
@@ -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)
29 changes: 29 additions & 0 deletions scripts/factorial_recursive_BHUPENDRArocxx.java
Original file line number Diff line number Diff line change
@@ -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.");
}
}
}