Showing posts with label factorial. Show all posts
Showing posts with label factorial. Show all posts

Factorial of a Number in C++

 This program calculates the factorial of a given positive integer.

#include <iostream>

int main() {

    int n;

    std::cout << "Enter a positive integer: ";

    std::cin >> n;

    unsigned long long factorial = 1;

    for(int i = 1; i <= n; ++i) {

        factorial *= i;

    }

    std::cout << "Factorial of " << n << " = " << factorial << std::endl;

    return 0;

}

Factorial of a Number in C

This program calculates the factorial of a given positive integer.

#include <stdio.h>

 int main() {
    int n, i;
    unsigned long long factorial = 1;
    printf("Enter a positive integer: ");
    scanf("%d", &n);
 
    for(i = 1; i <= n; ++i) {
        factorial *= i;
    }
 
    printf("Factorial of %d = %llu\n", n, factorial);
    return 0;
}

Factorial of a Number in Python

This program calculates the factorial of a given positive integer.

 
n = int(input("Enter a positive integer: "))
factorial = 1
for i in range(1, n + 1):
    factorial *= i
print(f"Factorial of {n} = {factorial}")

MS Excel Logical Functions

Logical functions in Excel are powerful tools that help you make decisions based on conditions. Whether you're comparing values or testi...

Post Count

Loading...