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

  • + 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;