看板 Math 關於我們 聯絡資訊
※ 引述《w181496 (短毛哥)》之銘言: : http://ppt.cc/48U~ : 題目如上圖 : 請高手指點一下~ : 感謝! hmm, 程式跑出來是51項(練習一下python XD) 而且遞減的情形並不平均, 前面還慢慢的,到最後卻突然快速遞減, 徒手估出正確的項數似乎不容易啊.... ====================== Python 3.0 code ======================= import math list_an = [3] #數列an的list變數 n = 0 #目前項數 an_sq = 16 #暫存變數 print('a[%d] = %f' %(n, list_an[n])) while an_sq > 0: list_an.append(math.sqrt(an_sq)) n+=1 print('a[%d] = %f' %(n, list_an[n])) an_sq = list_an[n]*list_an[n-1] - 1/list_an[n-1] print('a[%d] = sqrt(%f)!!' %(n+1, an_sq)) print('Answer: an has %d terms' %(n+1)) =============================================================== ====================== console display =================== a[0] = 3.000000 a[1] = 4.000000 a[2] = 3.415650 a[3] = 3.662322 a[4] = 3.495202 a[5] = 3.539422 a[6] = 3.476333 a[7] = 3.467229 a[8] = 3.430099 a[9] = 3.406541 a[10] = 3.375387 a[11] = 3.347364 a[12] = 3.316984 a[13] = 3.287006 a[14] = 3.255990 a[15] = 3.224629 a[16] = 3.192528 a[17] = 3.159842 a[18] = 3.126444 a[19] = 3.092345 a[20] = 3.057481 a[21] = 3.021822 a[22] = 2.985314 a[23] = 2.947908 a[24] = 2.909546 a[25] = 2.870165 a[26] = 2.829696 a[27] = 2.788061 a[28] = 2.745172 a[29] = 2.700932 a[30] = 2.655230 a[31] = 2.607941 a[32] = 2.558919 a[33] = 2.508000 a[34] = 2.454991 a[35] = 2.399665 a[36] = 2.341757 a[37] = 2.280944 a[38] = 2.216842 a[39] = 2.148971 a[40] = 2.076737 a[41] = 1.999377 a[42] = 1.915896 a[43] = 1.824950 a[44] = 1.724664 a[45] = 1.612286 a[46] = 1.483519 a[47] = 1.331021 a[48] = 1.140404 a[49] = 0.875557 a[50] = 0.348721 a[51] = sqrt(-0.836805)!! Answer: an has 51 terms ================================================================== -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.39.225.108 ※ 編輯: oNeChanPhile 來自: 114.27.8.196 (10/21 17:06)