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)

  let person = {
    name: "Alice",
    age: 25,
    isStudent: true,
  };
  • Accessing Properties:
  • Dot notation:

Dec 11, 2024
Read More
Tutorial
javascript

Easy JavaScript Tutorial for Beginners

JavaScript is one of the most popular programming languages used for creating dynamic and interactive web pages. It’s essential for front-end web development and works alongside HTML and CSS to give life to websites. If you’re a complete beginner, this tutorial will guide you through the basics of JavaScript, step by step.

No prior knowledge of programming is needed, but familiarity with HTML and CSS will be helpful.

Sep 18, 2024
Read More
Cheatsheet
solidity

Solidity Cheatsheet

interface MyInterface {
    function setData(uint _data) external;
    function getData() external view returns (uint);
}

contract MyContract is MyInterface {
    uint private data;

    function setData(uint _data) external override {
        data = _data;
    }

    function getData() external view override returns (uint) {
        return data;
    }
}

Libraries are similar to contracts but are meant to hold reusable code. They cannot hold state.

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!