DeveloperBreeze

Calculate Factorial

public static long factorial(int n) {
    if (n == 0 || n == 1) {
        return 1;
    }
    return n * factorial(n - 1);
}

int number = 5;
long result = factorial(number);
System.out.println("Factorial of " + number + " is " + result);

Related Posts

More content you might like

Tutorial
javascript

Non-Primitive Data Types (Objects, Arrays, and Functions)

    console.log(person.name); // "Alice"
  • Bracket notation:

Dec 11, 2024
Read More
Tutorial
javascript

Easy JavaScript Tutorial for Beginners

  • ==: Equal to
  • ===: Strict equal to (checks value and type)
  • !=: Not equal to
  • >, <: Greater than, less than
console.log(10 > 5);  // true

Sep 18, 2024
Read More
Cheatsheet
solidity

Solidity Cheatsheet

  • Receive: Specifically handles Ether transfers.

// Fallback function
fallback() external payable {
    // Logic to execute when no other function matches
}

// Receive function
receive() external payable {
    // Logic to execute when contract receives Ether directly
}

Aug 22, 2024
Read More
Code
javascript

Prime Number Check and Prime Number Generation in JavaScript

No preview available for this content.

Jan 26, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!