看板 Fortran 關於我們 聯絡資訊
改成 2^1 2^3 2^5 2^7 2^9 2^49 ----- - ----- + ----- - ----- + ----- .... ------ 2! 4! 6! 8! 10! 50! program Console4 implicit none integer:: i,c real(kind=8)::ss,a ss=0 a=0.5 c=-1 do i=1,100 a=a/i if(i/2*2==i)then a=a*4 c=c*-1 ss=ss+c*a write(*,*)i/2,ss endif enddo end program Console4 1 1.00000000000000 2 0.666666666666667 3 0.711111111111111 4 0.707936507936508 5 0.708077601410935 6 0.708073325851104 7 0.708073419819452 8 0.708073418253313 9 0.708073418273785 10 0.708073418273570 11 0.708073418273571 12 0.708073418273571 13 0.708073418273571 14 0.708073418273571 15 0.708073418273571 16 0.708073418273571 17 0.708073418273571 18 0.708073418273571 19 0.708073418273571 20 0.708073418273571 21 0.708073418273571 22 0.708073418273571 23 0.708073418273571 24 0.708073418273571 25 0.708073418273571 26 0.708073418273571 27 0.708073418273571 28 0.708073418273571 29 0.708073418273571 30 0.708073418273571 31 0.708073418273571 32 0.708073418273571 33 0.708073418273571 34 0.708073418273571 35 0.708073418273571 36 0.708073418273571 37 0.708073418273571 38 0.708073418273571 39 0.708073418273571 40 0.708073418273571 41 0.708073418273571 42 0.708073418273571 43 0.708073418273571 44 0.708073418273571 45 0.708073418273571 46 0.708073418273571 47 0.708073418273571 48 0.708073418273571 49 0.708073418273571 50 0.708073418273571 請按任意鍵繼續 . . . -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.138.214
jubilee2:你本來的驗算法比較準 只是沒辦法跌帶多次 11/09 11:38
jubilee2:我這個誤差比較大 但是可以算完 11/09 11:38
mon02118:感謝你~ 11/10 01:07