We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #57: Square root convergents
Project Euler #57: Square root convergents
Sort by
recency
|
17 Discussions
|
Please Login in order to post a comment
100 points. Python 3
JAva Code
Paythan
[def continued_fraction_expansion_sqrt2(N): numerators = [3] denominators = [2] iterations = []
Input
N = int(input())
Get the iterations where the numerator has more digits than the denominator
result = continued_fraction_expansion_sqrt2(N)
Output the result
for iteration in result: print(iteration)](https://)
include
using namespace std;
deque Add(deque a, deque b) { deque res;
}
bool DB = false;
int main() { int n; cin >> n;
}
HINTS:
This is like an IQ test: Find similarities of series (3/2, 7/5, 17/2, 41/29,...)
For example with 7/5:
Numerator (N) 7 = 3 + 2 x 2
Denominator (D) 5 = 3 + 2
Then we got:
N[i] = N[i-1] + 2*D[i-1]
D[i] = N[i-1] + D[i-1]
Then you can solve yourself