Website Summary Files Commits Branches @commit @diff @stats
path: root / Week04 / Exercise19.cpp
diff options
context:
space:
mode:
1 files changed, 15 insertions, 0 deletions
-rw-r--r--Week04/Exercise19.cpp15
diff --git a/Week04/Exercise19.cpp b/Week04/Exercise19.cpp
new file mode 100644
index 0000000..9238180
--- /dev/null
+++ b/Week04/Exercise19.cpp
@@ -0,0 +1,15 @@
+#include <iostream>
+
+int main() {
+ unsigned int n;
+ std::cin >> n;
+
+ float harmonic_number = 0.0;
+ for (unsigned int i = 1; i <= n; i++) {
+ harmonic_number += 1.0 / i;
+ }
+
+ std::cout << harmonic_number;
+
+ return 0;
+}