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);Calculate Factorial
Related Posts
More content you might like
Non-Primitive Data Types (Objects, Arrays, and Functions)
let person = {
name: "Alice",
age: 25,
isStudent: true,
};- Accessing Properties:
- Dot notation:
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.
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.
Prime Number Check and Prime Number Generation in JavaScript
No preview available for this content.
Discussion 0
Please sign in to join the discussion.
No comments yet. Be the first to share your thoughts!