abongasalifubashiru abongasalifubashiru
  • 01-09-2021
  • Computers and Technology
contestada

write a c++ program to calculate the factorial of a number

Respuesta :

tonb
tonb tonb
  • 01-09-2021

Answer:

#include <iostream>

int factorial(int n) {

 return (n > 1) ? n*factorial(n-1) : 1;

}

int main() {

 std::cout << factorial(5);

}

Explanation:

Above is an approach using recursion.

It will output 120, which is 5! = 5*4*3*2*1

Answer Link

Otras preguntas

A person standing at the top of mountain everest would be approximately 5.5 mi high. the radius of earth is 3959 mi. what is the distance to the horizon from th
Why does Eddie call the little boy a “future social worker”
Is Gatsby proud of his origins
ANSWER ASAPCharles Darwin’s findings were pivotal to the formation of the theory of evolution. He noted that the Galapagos Islands, which are located about 1,00
The interstate commerce Act (1887) was the first time that the federal government?
Show me how you did it on mathwatch Ill give Brainliest to anyone
What is the area of this triangle?
He coasted away from his home, passing over bicycles and cars, their antennae scraping the bottom of his canoe. every vehicle, old and new, was gone, unsalvagea
The area A of a circle is the product of π and the radius r squared i need written in a algebraic equation
help please I will give you the brianliest​