Search
 
SCRIPT & CODE EXAMPLE
 

CPP

calculate factorial

int factorial(int n) {
	int res = 1, i; 
    for (i = 2; i <= n; i++) 
        res *= i; 
    return res; 
}
Comment

Calculate factorial

// Calculate factorial

fn factorial(n: u64) -> u64 {
    (1..=n).product()
}

fn main() {
    println!("Factorial = {} ", factorial(5) );
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to empty an array c++ 
Cpp :: log in c++ 
Cpp :: concatenate two vectors c++ 
Cpp :: c++ if else 
Cpp :: cpp vs c# 
Cpp :: bee 1002 solution 
Cpp :: methods available for a stl vector 
Cpp :: cpp print variable value 
Cpp :: how to know datatype of something in c++ 
Cpp :: cpp getter as const 
Cpp :: Sort html elements in Jquery on condition 
Cpp :: c++ string find example 
Cpp :: Find the biggest element in the array 
Cpp :: print pattern and space in cpp 
Cpp :: c++ operator overloading 
Cpp :: what is meant by pragma once in c++ 
Cpp :: length of number c++ 
Cpp :: hello c++ 
Cpp :: SUMOFPROD2 solution 
Cpp :: c++ pointers and functions 
Cpp :: how to format decimal palces in c++ 
Cpp :: c++ initialise array 
Cpp :: convert std vector to array 
Cpp :: Fisher–Yates shuffle Algorithm c++ 
Cpp :: how to get euler constant in c++ 
Cpp :: how to remove the scroll bar in pyqt6 
Cpp :: What is a ~ in c++ 
Cpp :: remove comments c++ 
Cpp :: auto in c++ 
Cpp :: std::map get all keys 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =