当前位置: 移动技术网 > IT编程>开发语言>.net > ASP教程:等差数列和等比数列通项公式

ASP教程:等差数列和等比数列通项公式

2019年01月19日  | 移动技术网IT编程  | 我要评论

三星es73,2008年3月14日,dm500刷机文件

递归实例:等差数列和等比数列通项公式。

以下为引用的内容:
<%
==================================================
函数名:dengcha
作  用:等差数列公式
参  数: a1  ------等差数列第1项值
参  数: d   ------公差
参  数:n   ------第n项
返回值:等差数列第n项的值
==================================================
function dengcha(a1,d,n)
    if not(isnumeric(a1) or isnumeric(d) or isnumeric(n) or n<1) then exit function
    if n=1 then
        dengcha = a1
    else
        dengcha = dengcha(a1,d,n-1) + d
    end if
end function

==================================================
函数名:dengbi
作  用:等比数列公式
参  数: a1  ------等比数列第1项值
参  数: q   ------公比
参  数:n   ------第n项
返回值:等比数列第n项的值
==================================================
function dengbi(a1,q,n)
    if not(isnumeric(a1) or isnumeric(q) or isnumeric(n) or n<1) then exit function
    if n=1 then
        dengbi = a1
    else
        dengbi = dengcha(a1,q,n-1) * q
    end if
end function

response.write(dengcha(1,2,4))
response.write(dengbi(2,2,4))
%>

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网