-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdamianMessiah.cpp
80 lines (65 loc) · 1.87 KB
/
damianMessiah.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// damianMessiah.cpp
// Pi Factorization Module
//
// Created by Pedro Damian Sanchez Jr. on 2/4/20.
// Copyright © 2020 Pedro Damian Sanchez Jr. All rights reserved.
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
/*
struct MyStruct {
int i;
float f;
double d;
};
*/
int main() {
/*
string name;
string city;
cout << "Hello, my name is Indira; adjutant to the God-Emperor.\n";
cout << "\nMay I have your name: ";
getline(cin, name);
cout << "Please enter your place of birth: ";
getline(cin, city);
cout << "\nGreetings " << name << ", it is noted that you were born in " << city << ".\n\n";
cout << "sizeof(double) = " << sizeof(double) << endl;
cout << "sizeof(MyStruct) = " << sizeof(MyStruct) << endl;
*/
// Pi Declaration
long double pi = M_PI;
// Extends the precision count to 62 places past the decimal.
for (int i = 61; i < 62; i++) {
cout << "pi = " << fixed << setprecision(i) << pi << endl;
}
cout << endl;
// IMPORTANT
// Sets goal of the whole number you want to investigate.
// Will only work between 5 to 12 so far.
long double goal = 12;
// Numerical Analysis Using Binary Dissection.
// Newton's Method in C++.
long double n = 3;
long double step = n/4;
auto result = n * pi;
while(abs(goal - result) > 0.0) {
if (result > goal) {
n = n - step;
}
else {
n = n + step;
}
step /= 2;
result = n * pi;
cout << result << endl;
}
// Displays the Multiple of Pi needed to produce a your goal.
cout << endl;
cout << "The Pi-Fi n = " << n << endl;
cout << "Where n = " << fixed << setprecision(1) << goal << "/pi" << endl;
cout << endl;
return 0;
}