// Name: Connor McDowell // Date: 1/30/3024 // class: CIS116 // Assignment: homework 3 #include #include "header.h" using std::cin; using std::cout; using std::endl; int main() { int f = 0; int n = 0; int m = 0; int p = 0; // factorial section cout << "Enter a whole, positive number you would like to see go through a factorial calculation: "; cin >> f; cout << "The factorial of: " << f << " is: " << factorial(f) << endl; // fib section cout << "Please enter a whole, positive number to see the number located at your input's position in the fibonacci sequence: "; cin >> n; cout << "The number: " << fibonacci(n) << " is located at the position of input: " << n << endl; // powerfunc section cout << "Please enter a whole, positive number as the base for an exponential expression: "; cin >> m; cout << "And now a whole, positive number as the power to apply to the number: "; cin >> p; cout << m << " to the " << p << " power is: " << powerfunc(m, p); return 0; } int factorial(int f) { if (f == 0 || f == 1) return 1; long calc = f * factorial(f - 1); return calc; } int fibonacci(int n) { int a = 0, b = 1, c, i; if (n == 0 || n == 1) { return n; } else { return(fibonacci(n - 1) + fibonacci(n - 2)); } } int powerfunc(int m, int p) { if(p != 0) { return(m * powerfunc(m, p - 1)); } else { return 1; } }