Discrete Math and Computer Science
I need help with #2 the programming part is in C++ Thank you!
Answer 2:
(a)
/** * Program for Left Hand Side */ #include <iostream> #include <cmath> using namespace std; long long factorial(long long n){ if(n <= 1) return 1; return n * factorial(n - 1); } long long sigma(long long n){ long long sum = 0; for(int k = 0; k <= floor(n/2); k++){ sum += factorial(n - k)/(factorial(k) * factorial(n - 2*k)); } return sum; } int main(){ int n = 20; cout << "Left Hand Side for n = " << n << " = " << sigma(n) << endl; return 0; }
(b)
/** * Program for Right Hand Side */ #include <iostream> using namespace std; long long F(int n){ if(n <= 1) return n; return F(n - 1) + F(n - 2); } int main(){ int n = 20; int t = n + 1; cout << "Right Hand Side for t = " << t << " = " << F(t) << endl; cout << "Here t = n + 1" << endl; return 0; }
(c)
For n = 20
Output from (a)
t = 21 because t = n + 1 and n = 20
Output from (b)
Discrete Math and Computer Science I need help with #2 the programming part is in C++ Thank you! Main topic and prob...
Main topic and problems for the final project The main purpose of the project is to introduce you how to use a in an computer as a research tool Introductory Discrete Mathematics. In this project you will be asked to show how the Fibonacci sequence {Fn} is related to Pascal's triangle using the following identities by hand for small and then by computers with large n. Finally, to rove the identity by mathematical arguments, such as inductions or combinatorics. I...