1樓:
private sub command1_click()dim i, n, s as integern = val(text1.text)
s = 0
for i = n to 0 step -1s = s + i * (i + 1) / 2next i
text2.text = s
end sub
2樓:匿名使用者
private sub command1_click()dim n as integer, s as integer, p as integer
n = val(text1.text)
for i = 1 to n
p = p + i
s = s + p
next j
msgbox "結果是:" & str(s)end sub
3樓:
註釋:在窗體的單擊事件寫如下**,s 為輸出結果private sub form1_click()n = inputbox("請輸入求和項n:")for i = 1 to n
a =a + i
s = s + a
next i
print a
end sub
輸入正整數n計算11315的前n項
include int main for i 1 i n i printf sum 3f n sum return 0 示例執行結果 20sum 2.480 include int main void for int i 0 iprintf 數列前 d 項之和為 g n n,s return 0 v...
數列的前N項和,求數列前N項和
錯位相減法 形如an bncn,其中bn為等差數列,cn為等比數列 分別列出sn,再把所有式子同時乘以等比數列的公比,即ksn 然後錯一位,兩式相減即可。在這裡。兩邊乘以3得再相減即可。具體自己算。這裡我給你搜了個例如,求和sn 1 3x 5x 2 7x 3 2n 1 x n 1 x 0 當x 1時...
編寫程式輸入兩個正整數m和n輸出m和n之間的素
那個少年摩羯座 編寫程式,輸入兩個正整數m和n,輸出m和n之間的素數並統計素數的個數。要求定義並呼叫函式prime m 判斷m是否為素數,當m為素數時返回1,否則返回0。include int prime int m int main int argc,const char argv else pr...