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)

  const add = function (a, b) {
    return a + b;
  };
  console.log(add(3, 5)); // 8
  • Arrow Functions (ES6):

Dec 11, 2024
Read More
Tutorial
javascript

Easy JavaScript Tutorial for Beginners

console.log(10 > 5);  // true

Conditionals allow you to run different code based on conditions.

Sep 18, 2024
Read More
Cheatsheet
solidity

Solidity Cheatsheet

  • ERC721: Standard interface for non-fungible tokens (NFTs).

  • ERC1155: Standard for multi-token contracts.

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!