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

Tuesday, June 16, 2020

Factorial of a number using recursion in C++

#include<iostream> 

using namespace std;

int factorial (int a){

if(a > 1){
return a * factorial(a-1);
}
else
return 1;
}

int main(){
  int n;
  cin>>n;
  cout<<"The factorial of "<<n<<" is "<<factorial(n);
}

LeetCode 4 Median of Two Sorted Arrays in JavaScript

LeetCode 4, Median of Two Sorted Arrays , asks us to find the median of two already sorted arrays without actually merging them. The key ...

horizontal ads