fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <limits>
  4.  
  5. int main() {
  6. using namespace std;
  7.  
  8. double b=4095.1;
  9. double a=b+1;
  10. double x=1;
  11.  
  12. for (int i = 0; i < 100; ++i) {
  13. x = (a*x) - b;
  14. cout << "iter " << i << " - " << setprecision(numeric_limits<double>::max_digits10) << x << '\n';
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
iter 0 - 1.0000000000004547
iter 1 - 1.0000000018631452
iter 2 - 1.0000076316294826
iter 3 - 1.0312599175240718
iter 4 - 129.0437481703508
iter 5 - 524480.99688057392
iter 6 - 2148322516.2225189
iter 7 - 8799743854603.9609
iter 8 - 36044630802839192
iter 9 - 1.4764241223150964e+20
iter 10 - 6.047580847414867e+23
iter 11 - 2.477149590909604e+27
iter 12 - 1.014665243932483e+31
iter 13 - 4.1561703056718437e+34
iter 14 - 1.7024089189062442e+38
iter 15 - 6.9732371727318678e+41
iter 16 - 2.8563076783227004e+45
iter 17 - 1.1699721881177615e+49
iter 18 - 4.7923230797491637e+52
iter 19 - 1.9629834566960551e+56
iter 20 - 8.0405765369727123e+59
iter 21 - 3.2935005553093926e+63
iter 22 - 1.3490507624602805e+67
iter 23 - 5.5258468281135551e+70
iter 24 - 2.2634421192635937e+74
iter 25 - 9.2712852647156076e+77
iter 26 - 3.7976111572801603e+81
iter 27 - 1.5555395061335265e+85
iter 28 - 6.3716453710735387e+88
iter 29 - 2.6098896604454323e+92
iter 30 - 1.0690369038150536e+96
iter 31 - 4.3788820617168411e+99
iter 32 - 1.7936338812998356e+103
iter 33 - 7.3469037411922569e+106
iter 34 - 3.0093652414297603e+110
iter 35 - 1.2326660965420441e+114
iter 36 - 5.0491235980458676e+117
iter 37 - 2.068171516995568e+121
iter 38 - 8.4714373507655478e+124
iter 39 - 3.4699854532470764e+128
iter 40 - 1.4213407415045352e+132
iter 41 - 5.8219538112767265e+135
iter 42 - 2.3847305006370599e+139
iter 43 - 9.7680946036594616e+142
iter 44 - 4.0011092306049528e+146
iter 45 - 1.638894351948095e+150
iter 46 - 6.7130751550145923e+153
iter 47 - 2.7497427142455271e+157
iter 48 - 1.1263221131821104e+161
iter 49 - 4.613528007805243e+164
iter 50 - 1.8897472072771058e+168
iter 51 - 7.7405935357277545e+171
iter 52 - 3.1706245181694458e+175
iter 53 - 1.2987195088873868e+179
iter 54 - 5.3196849803536261e+182
iter 55 - 2.178996164802649e+186
iter 56 - 8.9253861906481319e+189
iter 57 - 3.6559274375513814e+193
iter 58 - 1.4975044376954216e+197
iter 59 - 6.1339279272442166e+200
iter 60 - 2.5125182182785039e+204
iter 61 - 1.0291525873890581e+208
iter 62 - 4.2155119132043214e+211
iter 63 - 1.7267158347676222e+215
iter 64 - 7.0728007307916577e+218
iter 65 - 2.8970899073395713e+222
iter 66 - 1.1866769969453618e+226
iter 67 - 4.8607476471878967e+229
iter 68 - 1.9910108437646346e+233
iter 69 - 8.1553795171443199e+236
iter 70 - 3.340525004017485e+240
iter 71 - 1.3683124468956022e+244
iter 72 - 5.6047446137290763e+247
iter 73 - 2.295759441229567e+251
iter 74 - 9.4036602472204307e+254
iter 75 - 3.8518332738639608e+258
iter 76 - 1.5777494273074171e+262
iter 77 - 6.462619429193912e+265
iter 78 - 2.6471535443921185e+269
iter 79 - 1.0843005633184557e+273
iter 80 - 4.441403537408727e+276
iter 81 - 1.8192433029579888e+280
iter 82 - 7.4518024932462182e+283
iter 83 - 3.0523328192585838e+287
iter 84 - 1.2502660460965086e+291
iter 85 - 5.1212147514159088e+294
iter 86 - 2.0977007743274705e+298
iter 87 - 8.5923921417227536e+301
iter 88 - 3.5195297451710577e+305
iter 89 - inf
iter 90 - inf
iter 91 - inf
iter 92 - inf
iter 93 - inf
iter 94 - inf
iter 95 - inf
iter 96 - inf
iter 97 - inf
iter 98 - inf
iter 99 - inf