'made by correy
'QQ:112426112
'email:leguanyuan@126.com
'此片文章是关于一些用脚本实现数学计算的。
'本人制作的一个计算器的代码
pi = 4 * Atn(1)
e = exp(1)
title="input as vbs grammar regulation:"&chr(13)&chr(10)
title=title&"notice:"&chr(13)&chr(10)&chr(13)&chr(10)
title=title&"e="&e&chr(13)&chr(10)
input=inputbox(title&"pi="&pi,"made by correy")
if len(input)=0 then wscript.quit
x=eval(input)
wscript.echo x
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'计算小e
'公式1:
'e=1+1/1!+1/2!+1/3!+1/4!+……+1/n!
'公式2:
'φkρ=αe
'其中,α和k为常数,φ是极角,ρ是极径,e是自然对数的底。
'公式3:
'e=(1+1/x)^x (-∞<n<+∞)
'第一种计算方法
e=1
m=1
n=0
do until n=99
m=(n+1)*m
e=e+1/m
n=n+1
loop
wscript.echo e
'第二种计算方法,利用语言本身。
e = exp(1)
wscript.echo e
'第三种计算方法,计算不太准确。
x=999999999
e=(1+1/x)^x
wscript.echo e
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
通项为自然数n的n次方的的和或积的级数,求和或积的表达式。
dim n,m
n=inputbox("input a number:","recursion")
m=factorial ( n )
if n<0 then msgbox "must be input a number bigger 0."
elseif n=0 then msgbox "0"&"!"&"is:"&"0"
elseif n>0 then msgbox n&"is:"&m
rem how to done not input and press sure case.
end if
Function Factorial (N)
If N <= 1 Then Factorial = 1
Else Factorial = Factorial(N - 1) + n^n
End If
End FunctiOn
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim n,m
n=inputbox("input a number:","recursion")
m=factorial ( n )
if n<0 then msgbox "must be input a number bigger 0."
elseif n=0 then msgbox "0"&"!"&"is:"&"0"
elseif n>0 then msgbox n&"is:"&m
rem how to done not input and press sure case.
end if
Function Factorial (N)
If N <= 1 Then Factorial = 1
Else Factorial = Factorial(N - 1)*n^n
End If
End Function
'设计一个函数求一个数的阶乘。
Function factorial (x)
m=1
n=0
do until n=x
m=(n+1)*m
n=n+1
loop
factorial=m
End Function
'Call factorial (9)
wscript.echo factorial (9)
'请看官根据以下公式实现如下功能。
'sin1=1-1/3!+1/5!-…+(-1)^(n-1)*1/(2*n-1)!+…(-∞<n<+∞)
'sinx=x-x^3/3!+x^5/5!-…+(-1)^(n-1)*x^(2*n-1)/(2*n-1)!+…(-∞<n<+∞)
'cosx=x-x^2/2!+x^4/4!-…+(-1)^n*x^(2*n)/(2*n)!+…(-∞<n<+∞)
'pi=x*sin(180/x)*cos(180/x)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'QQ:112426112
'email:leguanyuan@126.com
'此片文章是关于一些用脚本实现数学计算的。
'本人制作的一个计算器的代码
pi = 4 * Atn(1)
e = exp(1)
title="input as vbs grammar regulation:"&chr(13)&chr(10)
title=title&"notice:"&chr(13)&chr(10)&chr(13)&chr(10)
title=title&"e="&e&chr(13)&chr(10)
input=inputbox(title&"pi="&pi,"made by correy")
if len(input)=0 then wscript.quit
x=eval(input)
wscript.echo x
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'计算小e
'公式1:
'e=1+1/1!+1/2!+1/3!+1/4!+……+1/n!
'公式2:
'φkρ=αe
'其中,α和k为常数,φ是极角,ρ是极径,e是自然对数的底。
'公式3:
'e=(1+1/x)^x (-∞<n<+∞)
'第一种计算方法
e=1
m=1
n=0
do until n=99
m=(n+1)*m
e=e+1/m
n=n+1
loop
wscript.echo e
'第二种计算方法,利用语言本身。
e = exp(1)
wscript.echo e
'第三种计算方法,计算不太准确。
x=999999999
e=(1+1/x)^x
wscript.echo e
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
通项为自然数n的n次方的的和或积的级数,求和或积的表达式。
dim n,m
n=inputbox("input a number:","recursion")
m=factorial ( n )
if n<0 then msgbox "must be input a number bigger 0."
elseif n=0 then msgbox "0"&"!"&"is:"&"0"
elseif n>0 then msgbox n&"is:"&m
rem how to done not input and press sure case.
end if
Function Factorial (N)
If N <= 1 Then Factorial = 1
Else Factorial = Factorial(N - 1) + n^n
End If
End FunctiOn
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim n,m
n=inputbox("input a number:","recursion")
m=factorial ( n )
if n<0 then msgbox "must be input a number bigger 0."
elseif n=0 then msgbox "0"&"!"&"is:"&"0"
elseif n>0 then msgbox n&"is:"&m
rem how to done not input and press sure case.
end if
Function Factorial (N)
If N <= 1 Then Factorial = 1
Else Factorial = Factorial(N - 1)*n^n
End If
End Function
'设计一个函数求一个数的阶乘。
Function factorial (x)
m=1
n=0
do until n=x
m=(n+1)*m
n=n+1
loop
factorial=m
End Function
'Call factorial (9)
wscript.echo factorial (9)
'请看官根据以下公式实现如下功能。
'sin1=1-1/3!+1/5!-…+(-1)^(n-1)*1/(2*n-1)!+…(-∞<n<+∞)
'sinx=x-x^3/3!+x^5/5!-…+(-1)^(n-1)*x^(2*n-1)/(2*n-1)!+…(-∞<n<+∞)
'cosx=x-x^2/2!+x^4/4!-…+(-1)^n*x^(2*n)/(2*n)!+…(-∞<n<+∞)
'pi=x*sin(180/x)*cos(180/x)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'素数(也叫质数,我叫他光棍数或独身数)的算法。
'made by correy
'QQ:112426112
'Email:leguanyuan@126.com
'Homepage:http://correy.webs.com
'不足之处,敬请指导。
for n = 1 to 10000 '显示10000以内的素数。
call prime (n)
next
'made by correy
'QQ:112426112
'Email:leguanyuan@126.com
'Homepage:http://correy.webs.com
'不足之处,敬请指导。
for n = 1 to 10000 '显示10000以内的素数。
call prime (n)
next
function prime(x) '是否是素数。
if x=1 then
exit function
end if
exit function
end if
if x = 2 then
wscript.echo x
exit function
end if
wscript.echo x
exit function
end if
y = x
for counter = 2 to y-1
z = x mod counter
if z = 0 then
exit function
end if
exit function
end if
next
wscript.echo x
end function
'made at 2010.07.09
'made at 2010.07.09
'比较整齐的显示9*9乘法表。
'小玩意,见效了。
'不足之处,敬请指导。
'在命令提示符下输入wscript.exe,显示的不是很整齐。
'made by correy
'QQ:112426112
'Email:leguanyuan@126.com
'Homepage:http://correy.webs.com
for x = 1 to 9
for y = 1 to 9
if len (x*y) = 2 then
if strreverse( mid (strreverse (wscript.FullName),1,11)) = "WScript.exe" then '注意ws要大写。
z = z & x*y & " "'引号里面的空格可不要乱改呀!
else
z = z & x*y & " "'比上一个多一个空格
end if
else
z = z & x*y & " "'比上一个多一个空格
end if
next
z = z & chr(13) & chr (10)
next
wscript.echo z
'made at 2010.07.13
'小玩意,见效了。
'不足之处,敬请指导。
'在命令提示符下输入wscript.exe,显示的不是很整齐。
'made by correy
'QQ:112426112
'Email:leguanyuan@126.com
'Homepage:http://correy.webs.com
for x = 1 to 9
for y = 1 to 9
if len (x*y) = 2 then
if strreverse( mid (strreverse (wscript.FullName),1,11)) = "WScript.exe" then '注意ws要大写。
z = z & x*y & " "'引号里面的空格可不要乱改呀!
else
z = z & x*y & " "'比上一个多一个空格
end if
else
z = z & x*y & " "'比上一个多一个空格
end if
next
z = z & chr(13) & chr (10)
next
wscript.echo z
'made at 2010.07.13
没有评论:
发表评论