我有以下公式:
F = X / 1+4+9+16+....+n^2
如何在QBasic
中编写一个找到F
结果的程序?
感谢。
答案 0 :(得分:2)
答案 1 :(得分:1)
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
答案 2 :(得分:0)
功率倍增器:
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