aboutsummaryrefslogtreecommitdiff
path: root/Hmw-3
diff options
context:
space:
mode:
authorraquelc <[email protected]>2024-02-01 19:58:51 -0800
committerraquelc <[email protected]>2024-02-01 19:58:51 -0800
commit80fccf0cb524ddae17454726137a3f4fb7179760 (patch)
treeb4f1476479d6f4f3dbeefdafcb0aec3450ff0c7b /Hmw-3
parenthmw3 setup of pages (diff)
downloadhomework-3-raquel191-main.tar.xz
homework-3-raquel191-main.zip
hm3 completeHEADmain
Diffstat (limited to 'Hmw-3')
-rw-r--r--Hmw-3/Hmw-3/Header.h5
-rw-r--r--Hmw-3/Hmw-3/Source.cpp57
2 files changed, 62 insertions, 0 deletions
diff --git a/Hmw-3/Hmw-3/Header.h b/Hmw-3/Hmw-3/Header.h
index a149b6e..1ff2024 100644
--- a/Hmw-3/Hmw-3/Header.h
+++ b/Hmw-3/Hmw-3/Header.h
@@ -2,5 +2,10 @@
#define MY_HEADER_H
+int base( int rad);
+
+long fact(int a);
+
+long fib(int b);
#endif \ No newline at end of file
diff --git a/Hmw-3/Hmw-3/Source.cpp b/Hmw-3/Hmw-3/Source.cpp
index 61ac26a..10e64b2 100644
--- a/Hmw-3/Hmw-3/Source.cpp
+++ b/Hmw-3/Hmw-3/Source.cpp
@@ -5,8 +5,65 @@
#include <iostream>
#include "Header.h"
+#include <cmath>
int main() {
+ std::cout << "enter a number" << std::endl;
+ int i;
+ std::cin >> i;
+ std::cout << base(i) << std::endl;
+
+ std::cout << "factorial sequence product:" << std::endl;
+ std::cout << "Enter a number: ";
+ int l;
+ std::cin >> l;
+ std::cout << fact(l) << std::endl;
+
+ std::cout << "fibonachi sequence:" << std::endl;
+ std::cout << "enter num ";
+ int h;
+ std::cin >> h;
+ //std::cout << fib(h) << std::endl;
+
+ int b = h, a =0;
+ for (a = 0;a < b;a++)
+ std::cout << fib(a) << " ";
+
return 0;
+}
+
+
+int base(int rad) {
+ int j;
+ std::cout << "Enter another number for the previuos number to be x to the nth power" << std::endl;
+ double result = 0;
+ std::cin >> j;
+ result = pow(rad, j);
+ return result;
+ // size_t couled be usesd to output bigger numbers
+}
+
+
+
+long fact(int a)
+{
+
+ if (a == 0 || a == 1) {
+ return 1;
+ }
+ else {
+ return a * fact(a - 1);
+ }
+ //Size_t could be used to store the result of the multiplied numbers
+}
+
+long fib(int b) {
+
+ if (b <= 1)
+ return b;
+
+
+ return fib(b - 1) + fib(b - 2);
+ //size_t to store the result after each loop
} \ No newline at end of file