Dim n,f
n=inputbox("enter a number")
f=1
If n<0 Then
msgbox "invalid number"
else if n=0 or n=1 then
msgbox "the factorial of given number is : "& f
else
For i=1 to n
f=f*i
Next
msgbox "the factorial of given number is : "&f
end if
End if
Function
---------------------------
Function Factorial(a)
x=1
For i=1 to a
x=x*i
next
Factorial=x
End Function
Msgbox Factorial(5)
n=inputbox("enter a number")
f=1
If n<0 Then
msgbox "invalid number"
else if n=0 or n=1 then
msgbox "the factorial of given number is : "& f
else
For i=1 to n
f=f*i
Next
msgbox "the factorial of given number is : "&f
end if
End if
Function
---------------------------
Function Factorial(a)
x=1
For i=1 to a
x=x*i
next
Factorial=x
End Function
Msgbox Factorial(5)
No comments:
Post a Comment
Note: only a member of this blog may post a comment.