- All Contests
- ProjectEuler+
- Project Euler #197: Investigating the behaviour of a recursively defined sequence
- Discussions

# Project Euler #197: Investigating the behaviour of a recursively defined sequence

# Project Euler #197: Investigating the behaviour of a recursively defined sequence

+ 1 comment i can't understand the question can anyone please explain me the the problem!!!!

+ 0 comments This worked for me, it doesn't require 10^12 iterations: My implementation-

`cin >>u0>>b; //double a = reccur(1000000); double f_val = u0; double pf_val; for(unsigned long long i=1;i<=1000001; i++){ pf_val = f_val; f_val = fn_1(pf_val); if(f_val == pf_val) break; } //double b = fn_1(f_val); cout<<setprecision(16)<<f_val + pf_val; return 0;`

+ 0 comments import math def function(x,b): tem=2**(b-x**2) tem=math.floor(tem)

*10**(-9) return(tem) num=list(map(float,input().split(" "))) x_=num[0] b_=num[1] k=function(x_,b_) for i in range(100): k1=function(k,30) if(k==k1): k1=k1+k1 break else: k=k1my code is this it shows error i cannot undestand whats worng in this can anyone help me

print(k1)

+ 1 comment I came up with a solution in C# and I pass the test case. I can run the program within the constraints (28 <= b <= 32 and 0 <= u0 <= 10) by using "Test against custom input". I get some results and it does not matter if they are good of bad - but when I submit my solution, all test cases apart for first give "runtime error". If there is a mistake in my code, I would expect to get runtime error when checking with custom input. Can some admin check what is going on please?

+ 1 comment I began with the following conjucture: there is always an index

*i*such that*u*, for some_{i}= u_{j}*j < i*, so that*u*, for all_{i+k}= u_{j+k}*k ≥ 0*. I am not sure why this must be true, but assuming that this is true, following is a very high-level algorithm to solve this problem.- Collect the values of
*u*in an array, until finding an index*i*such that*u*, for some_{i}= u_{j}*j < i*. Using a dictionary that maps each*u*to_{i}*i*can make the lookup process faster. - Find the largest
*k*such that*k ≤ n*and*u*._{k}= u_{j} - Output
*u*, where_{m}+ u_{m+1}*m = n-k+j*.

I implemented this, and it turns out that the conjucture is true at least for the cases considered in this problem. If someone can provide a proof of why there must be such a cycle in every case, it would be great.

- Collect the values of

Sort 20 Discussions, By:

Please Login in order to post a comment