Function f(m As Integer) As Long
Dim i As Integer, s As Long
s = 1
For i = 1 To m
s = s * i
Next i
f = s
End Function
Private Sub FORM_Click()
Dim i As Integer, L As Long
s = 0
For i = 1 To 10
L = L + f(i)
Next
Print L
End Sub
Function f(n As Integer) As Long
If n > 1 Then
f = n * f(n - 1)
Else
f = 1
End If
End Function
Private Sub Form_Click()
n = 10
For a = 1 to n
Sum = Sum + f(n)
Next For
Print Sum
End Sub
扩展资料:
在初等数学中,变量是表示数字的字母字符,具有任意性和未知性。把变量当作行滚是显式数字一样,对其进行代数计算,可以在单个计算中解决很多问题。
变量的概念也是微积分的基础。通常,函数y = f(x)涉及两个变量y和x,分别表示函数的值和参数。术语“变量”来源于当参数(也称为“函数的变量”)变化时,值相应变化。
在高级数学中,变量是表示数学对象的符号,可以是数字,向量,矩阵,甚至是函数。在这种情况下,变量的原始属性将会消失。
参考资料来源:百档岩余度百科枣旁-变量
#include <昌睁stdio.h>耐此岁
int main ()
{
int i,j,n = 1,m = 1;
int sum = 0;
for(i=1; i<=10; i++)
{
for(j=1; j<=i; j++)
{
if(j==i)
{
n = m*j;
m = n;
}
}
sum += n;
}
printf("扒手the sum is %d\n",sum);
return 0;
}
Private Sub Command1_Click()
Randomize
Dim x!, y!, z!
x = Int(Rnd * 10)
y = Int(Rnd * 10)
z = Int(Rnd * 10)
Cls
Print "粗历孝x=" & x & ",y="岩稿 & y & "烂明,z=" & z
End Sub