Last active
January 6, 2019 21:51
-
-
Save Sam-Belliveau/cc097ed7c7cd1938631a7488a375c0cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <cstdint> | |
| using Int = std::uintmax_t; | |
| using Float = long double; | |
| constexpr Float getPhi() | |
| { | |
| Float Phi = 1; | |
| for(Int i = 0; i < 0xffff; ++i) | |
| Phi = 1/Phi + 1; | |
| return Phi; | |
| } | |
| constexpr Float Phi = getPhi(); | |
| Int getNextInt(Int num) | |
| { return (Float(num)*Phi) + Float(0.5); } | |
| Int getLastInt(Int num) | |
| { return (Float(num)/Phi) + Float(0.5); } | |
| int main(int argc, char** argv) | |
| { | |
| while(1) | |
| { | |
| std::cout << "Enter Number: "; | |
| std::string inputStr; | |
| std::getline(std::cin, inputStr); | |
| const Int input = std::stoll(inputStr); | |
| std::cout | |
| << getLastInt(getLastInt(input)) << ' ' | |
| << getLastInt(input) << " [" | |
| << input << "] " | |
| << getNextInt(input) << ' ' | |
| << getNextInt(getNextInt(input)) << "\n\n"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment