From 2cc1d8e69db1dbf65806a3c04cc485625844a3e5 Mon Sep 17 00:00:00 2001 From: sanyam-kaul Date: Thu, 10 Oct 2019 10:55:25 +0530 Subject: [PATCH] Create factUsingDP.cpp This file contains the code in C++ that finds the factorial of the number using Dynamic Programing. --- Dynamic Programming/factUsingDP.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Dynamic Programming/factUsingDP.cpp diff --git a/Dynamic Programming/factUsingDP.cpp b/Dynamic Programming/factUsingDP.cpp new file mode 100644 index 00000000..08c70c30 --- /dev/null +++ b/Dynamic Programming/factUsingDP.cpp @@ -0,0 +1,15 @@ +#include +using namespace std; + +int main(){ + int n; + cout<<"Enter the number whose factorial you want:-"<>n; + int arr[n]; + arr[0] = 1; + + for( int i = 1; i < n; i++) + arr[i] = (i+1)*arr[i-1]; + cout<<"Factorial of "<