2

我有以下公式:

F =  X / 1+4+9+16+....+n^2

我怎样才能编写一个QBasic找到结果的程序F

谢谢。

4

3 回答 3

2
CLS
INPUT "Input the value of n: ", n%
INPUT "The value of X: ", X
denominator% = 0
FOR i% = 1 TO n%
    denominator% = denominator% + i% ^ 2
NEXT i%
F = X / denominator%
PRINT "F = "; F
于 2013-06-25T20:29:59.600 回答
2

这个有用的页面中,前 n 个自然数的平方和为:

前 n 个自然数的平方和

所以你只需要计算:

F = X * 6 / (n * (n + 1) * (2 * n + 1))
于 2012-12-06T12:35:39.270 回答
1

功率倍增器:

DEFDBL A-Z
INPUT "Input the value of n: ", n
INPUT "The value of X: ", X
INPUT "The power: ", p
denominator = 0
FOR i = 1 TO n
    denominator = denominator + i ^ p
NEXT
F = X / denominator
PRINT "F = "; F
END
于 2018-02-12T06:02:01.473 回答