fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main(void) {
  5. double Tm,a=1,b=2,h,ci;
  6. int i,No,m;
  7.  
  8. for(No=1;No<500;No++){
  9. Tm=0;
  10. m=No;
  11. h=(b-a)/m;
  12. ci=a+h;
  13. Tm=(pow(a,3)+pow(b,3))/2;
  14. for(i=1;i<m;i++){
  15. Tm+=pow(ci,3);
  16. ci+=h;
  17. }
  18. Tm*=h;
  19. printf("%8d %.12lf\n",No,Tm);
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
       1 4.500000000000
       2 3.937500000000
       3 3.833333333333
       4 3.796875000000
       5 3.780000000000
       6 3.770833333333
       7 3.765306122449
       8 3.761718750000
       9 3.759259259259
      10 3.757500000000
      11 3.756198347107
      12 3.755208333333
      13 3.754437869822
      14 3.753826530612
      15 3.753333333333
      16 3.752929687500
      17 3.752595155709
      18 3.752314814815
      19 3.752077562327
      20 3.751875000000
      21 3.751700680272
      22 3.751549586777
      23 3.751417769376
      24 3.751302083333
      25 3.751200000000
      26 3.751109467456
      27 3.751028806584
      28 3.750956632653
      29 3.750891795482
      30 3.750833333333
      31 3.750780437045
      32 3.750732421875
      33 3.750688705234
      34 3.750648788927
      35 3.750612244898
      36 3.750578703704
      37 3.750547845142
      38 3.750519390582
      39 3.750493096647
      40 3.750468750000
      41 3.750446162998
      42 3.750425170068
      43 3.750405624662
      44 3.750387396694
      45 3.750370370370
      46 3.750354442344
      47 3.750339520145
      48 3.750325520833
      49 3.750312369846
      50 3.750300000000
      51 3.750288350634
      52 3.750277366864
      53 3.750266998932
      54 3.750257201646
      55 3.750247933884
      56 3.750239158163
      57 3.750230840259
      58 3.750222948870
      59 3.750215455329
      60 3.750208333333
      61 3.750201558721
      62 3.750195109261
      63 3.750188964475
      64 3.750183105469
      65 3.750177514793
      66 3.750172176309
      67 3.750167075072
      68 3.750162197232
      69 3.750157529931
      70 3.750153061224
      71 3.750148780004
      72 3.750144675926
      73 3.750140739351
      74 3.750136961286
      75 3.750133333333
      76 3.750129847645
      77 3.750126496880
      78 3.750123274162
      79 3.750120173049
      80 3.750117187500
      81 3.750114311843
      82 3.750111540750
      83 3.750108869212
      84 3.750106292517
      85 3.750103806228
      86 3.750101406166
      87 3.750099088387
      88 3.750096849174
      89 3.750094685015
      90 3.750092592593
      91 3.750090568772
      92 3.750088610586
      93 3.750086715227
      94 3.750084880036
      95 3.750083102493
      96 3.750081380208
      97 3.750079710915
      98 3.750078092461
      99 3.750076522804
     100 3.750075000000
     101 3.750073522204
     102 3.750072087659
     103 3.750070694693
     104 3.750069341716
     105 3.750068027211
     106 3.750066749733
     107 3.750065507905
     108 3.750064300412
     109 3.750063125999
     110 3.750061983471
     111 3.750060871682
     112 3.750059789541
     113 3.750058736001
     114 3.750057710065
     115 3.750056710775
     116 3.750055737218
     117 3.750054788516
     118 3.750053863832
     119 3.750052962361
     120 3.750052083333
     121 3.750051226009
     122 3.750050389680
     123 3.750049573666
     124 3.750048777315
     125 3.750048000000
     126 3.750047241119
     127 3.750046500093
     128 3.750045776367
     129 3.750045069407
     130 3.750044378698
     131 3.750043703747
     132 3.750043044077
     133 3.750042399231
     134 3.750041768768
     135 3.750041152263
     136 3.750040549308
     137 3.750039959508
     138 3.750039382483
     139 3.750038817867
     140 3.750038265306
     141 3.750037724460
     142 3.750037195001
     143 3.750036676610
     144 3.750036168981
     145 3.750035671819
     146 3.750035184838
     147 3.750034707761
     148 3.750034240321
     149 3.750033782262
     150 3.750033333333
     151 3.750032893294
     152 3.750032461911
     153 3.750032038959
     154 3.750031624220
     155 3.750031217482
     156 3.750030818540
     157 3.750030427198
     158 3.750030043262
     159 3.750029666548
     160 3.750029296875
     161 3.750028934069
     162 3.750028577961
     163 3.750028228386
     164 3.750027885187
     165 3.750027548209
     166 3.750027217303
     167 3.750026892323
     168 3.750026573129
     169 3.750026259585
     170 3.750025951557
     171 3.750025648918
     172 3.750025351541
     173 3.750025059307
     174 3.750024772097
     175 3.750024489796
     176 3.750024212293
     177 3.750023939481
     178 3.750023671254
     179 3.750023407509
     180 3.750023148148
     181 3.750022893074
     182 3.750022642193
     183 3.750022395413
     184 3.750022152646
     185 3.750021913806
     186 3.750021678807
     187 3.750021447568
     188 3.750021220009
     189 3.750020996053
     190 3.750020775623
     191 3.750020558647
     192 3.750020345052
     193 3.750020134769
     194 3.750019927729
     195 3.750019723866
     196 3.750019523115
     197 3.750019325414
     198 3.750019130701
     199 3.750018938916
     200 3.750018750000
     201 3.750018563897
     202 3.750018380551
     203 3.750018199908
     204 3.750018021915
     205 3.750017846520
     206 3.750017673673
     207 3.750017503326
     208 3.750017335429
     209 3.750017169937
     210 3.750017006803
     211 3.750016845983
     212 3.750016687433
     213 3.750016531112
     214 3.750016376976
     215 3.750016224987
     216 3.750016075103
     217 3.750015927287
     218 3.750015781500
     219 3.750015637706
     220 3.750015495868
     221 3.750015355951
     222 3.750015217921
     223 3.750015081743
     224 3.750014947385
     225 3.750014814815
     226 3.750014684000
     227 3.750014554911
     228 3.750014427516
     229 3.750014301787
     230 3.750014177694
     231 3.750014055209
     232 3.750013934304
     233 3.750013814953
     234 3.750013697129
     235 3.750013580806
     236 3.750013465958
     237 3.750013352561
     238 3.750013240590
     239 3.750013130022
     240 3.750013020833
     241 3.750012913001
     242 3.750012806502
     243 3.750012701316
     244 3.750012597420
     245 3.750012494794
     246 3.750012393417
     247 3.750012293268
     248 3.750012194329
     249 3.750012096579
     250 3.750012000000
     251 3.750011904573
     252 3.750011810280
     253 3.750011717102
     254 3.750011625023
     255 3.750011534025
     256 3.750011444092
     257 3.750011355206
     258 3.750011267352
     259 3.750011180513
     260 3.750011094675
     261 3.750011009821
     262 3.750010925937
     263 3.750010843008
     264 3.750010761019
     265 3.750010679957
     266 3.750010599808
     267 3.750010520557
     268 3.750010442192
     269 3.750010364699
     270 3.750010288066
     271 3.750010212279
     272 3.750010137327
     273 3.750010063197
     274 3.750009989877
     275 3.750009917355
     276 3.750009845621
     277 3.750009774662
     278 3.750009704467
     279 3.750009635025
     280 3.750009566327
     281 3.750009498360
     282 3.750009431115
     283 3.750009364582
     284 3.750009298750
     285 3.750009233610
     286 3.750009169153
     287 3.750009105367
     288 3.750009042245
     289 3.750008979778
     290 3.750008917955
     291 3.750008856768
     292 3.750008796209
     293 3.750008736270
     294 3.750008676940
     295 3.750008618213
     296 3.750008560080
     297 3.750008502534
     298 3.750008445566
     299 3.750008389168
     300 3.750008333333
     301 3.750008278054
     302 3.750008223323
     303 3.750008169134
     304 3.750008115478
     305 3.750008062349
     306 3.750008009740
     307 3.750007957644
     308 3.750007906055
     309 3.750007854966
     310 3.750007804370
     311 3.750007754262
     312 3.750007704635
     313 3.750007655483
     314 3.750007606800
     315 3.750007558579
     316 3.750007510816
     317 3.750007463503
     318 3.750007416637
     319 3.750007370210
     320 3.750007324219
     321 3.750007278656
     322 3.750007233517
     323 3.750007188797
     324 3.750007144490
     325 3.750007100592
     326 3.750007057097
     327 3.750007014000
     328 3.750006971297
     329 3.750006928983
     330 3.750006887052
     331 3.750006845502
     332 3.750006804326
     333 3.750006763520
     334 3.750006723081
     335 3.750006683003
     336 3.750006643282
     337 3.750006603915
     338 3.750006564896
     339 3.750006526222
     340 3.750006487889
     341 3.750006449893
     342 3.750006412230
     343 3.750006374895
     344 3.750006337885
     345 3.750006301197
     346 3.750006264827
     347 3.750006228770
     348 3.750006193024
     349 3.750006157585
     350 3.750006122449
     351 3.750006087613
     352 3.750006053073
     353 3.750006018827
     354 3.750005984870
     355 3.750005951200
     356 3.750005917813
     357 3.750005884707
     358 3.750005851877
     359 3.750005819322
     360 3.750005787037
     361 3.750005755020
     362 3.750005723268
     363 3.750005691779
     364 3.750005660548
     365 3.750005629574
     366 3.750005598853
     367 3.750005568383
     368 3.750005538162
     369 3.750005508185
     370 3.750005478451
     371 3.750005448958
     372 3.750005419702
     373 3.750005390681
     374 3.750005361892
     375 3.750005333333
     376 3.750005305002
     377 3.750005276896
     378 3.750005249013
     379 3.750005221350
     380 3.750005193906
     381 3.750005166677
     382 3.750005139662
     383 3.750005112858
     384 3.750005086263
     385 3.750005059875
     386 3.750005033692
     387 3.750005007712
     388 3.750004981932
     389 3.750004956351
     390 3.750004930966
     391 3.750004905776
     392 3.750004880779
     393 3.750004855972
     394 3.750004831354
     395 3.750004806922
     396 3.750004782675
     397 3.750004758612
     398 3.750004734729
     399 3.750004711026
     400 3.750004687500
     401 3.750004664150
     402 3.750004640974
     403 3.750004617971
     404 3.750004595138
     405 3.750004572474
     406 3.750004549977
     407 3.750004527646
     408 3.750004505479
     409 3.750004483474
     410 3.750004461630
     411 3.750004439945
     412 3.750004418419
     413 3.750004397048
     414 3.750004375831
     415 3.750004354769
     416 3.750004333857
     417 3.750004313096
     418 3.750004292484
     419 3.750004272019
     420 3.750004251701
     421 3.750004231527
     422 3.750004211496
     423 3.750004191607
     424 3.750004171858
     425 3.750004152249
     426 3.750004132778
     427 3.750004113443
     428 3.750004094244
     429 3.750004075179
     430 3.750004056247
     431 3.750004037446
     432 3.750004018776
     433 3.750004000235
     434 3.750003981822
     435 3.750003963535
     436 3.750003945375
     437 3.750003927339
     438 3.750003909427
     439 3.750003891636
     440 3.750003873967
     441 3.750003856418
     442 3.750003838988
     443 3.750003821675
     444 3.750003804480
     445 3.750003787401
     446 3.750003770436
     447 3.750003753585
     448 3.750003736846
     449 3.750003720220
     450 3.750003703704
     451 3.750003687297
     452 3.750003671000
     453 3.750003654810
     454 3.750003638728
     455 3.750003622751
     456 3.750003606879
     457 3.750003591111
     458 3.750003575447
     459 3.750003559884
     460 3.750003544424
     461 3.750003529063
     462 3.750003513802
     463 3.750003498640
     464 3.750003483576
     465 3.750003468609
     466 3.750003453738
     467 3.750003438963
     468 3.750003424282
     469 3.750003409695
     470 3.750003395202
     471 3.750003380800
     472 3.750003366490
     473 3.750003352270
     474 3.750003338140
     475 3.750003324100
     476 3.750003310148
     477 3.750003296283
     478 3.750003282506
     479 3.750003268814
     480 3.750003255209
     481 3.750003241687
     482 3.750003228250
     483 3.750003214897
     484 3.750003201625
     485 3.750003188437
     486 3.750003175329
     487 3.750003162302
     488 3.750003149355
     489 3.750003136488
     490 3.750003123699
     491 3.750003110987
     492 3.750003098354
     493 3.750003085798
     494 3.750003073317
     495 3.750003060912
     496 3.750003048582
     497 3.750003036326
     498 3.750003024145
     499 3.750003012036