Function to generate the fibonnacci series, Visual Basic Programming

Assignment Help:

The following code will do the job:

<SCRIPT LANGUAGE=vbscript>

<!--

Function IsPrime(str)

str=trim(str) Dim bln,ctr bln=true ctr=1

if(cint(str)<1)then

IsPrime=false exit function end if

if(cint(str)=1 or cint(str)=2 or cint(str)=3)then

IsPrime=true exit function end if

for ctr=cint(str)-1 to 2 step -1 if(cint(str)mod(ctr)=0)then bln=false

end if

next IsPrime=bln End Function

Function IsEven(str) str=trim(str) if(str="0")then IsEven=true

exit function

end if if(cint(str)mod(2)=0)then IsEven=true

else IsEven=false end if

End Function

Sub main()

str=text1.value

Dim blnEven,blnPrime

if not(isnumeric(str))then msgbox "Not numeric value" exit sub

end if

if(IsEven(str))then msgbox "Even" else

msgbox "Odd" end if

if(IsPrime(str))then msgbox "prime" else

msgbox "not prime"

end if

End Sub

}

//-->

</SCRIPT>

2.       Use the given function to generate the fibonnacci series.

FUNCTION fib (n)

if (N=0) or (N=1) then

Fib = 1

ElseFib = Fib (N- 1) + Fib (N-2) END If

END FUNCTION

3.       Use the given function to determine the factorial

Function Factorial(n) Dim i

If n < 0 Then

Factorial = 0

Exit Function End If Factorial = 1

For i = 2 To n

Factorial = Factorial * i

Next

End Function


Related Discussions:- Function to generate the fibonnacci series

Dynamic link library - database applications, DYNAMIC LINK LIBRARY   T...

DYNAMIC LINK LIBRARY   The dynamic link library (dll) permits one copy of a function to be shared among some parallel executing programs. The dll is a file that contains a num

Application that determines the optimal inventory policy, Objective: To dev...

Objective: To develop an Application (Excel + VBA) that determines the optimal inventory policy under an All-Units Discount scheme. APPLICATION CHARACTERISTICS Consider the

Operator precedence - vbscript operators, While several operations take pla...

While several operations take place in an expression, each part is evaluated & resolved in a predetermined order called operator precedence. You can employ parentheses to override

Introduction to visual c++ programming, INTRODUCTION to VISUAL C++ PROGRAMM...

INTRODUCTION to VISUAL C++ PROGRAMMING This section introduces you to develop the applications using VC++. The Single document interface (SDI), multiple document interface (MDI

Create an application, 1. Create a new solution file named Ch03HandsOnProje...

1. Create a new solution file named Ch03HandsOnProject1. 2. Rename the form and set the filename of the form to frmMain and frmMain.vb, respectively. 3. Set the appropriate p

External application window position, I have an external application I open...

I have an external application I open from visual studio (excel). I want to reposition where that opens (top, left).. How do I do that?

Help, Assume that s is a string variable that is supposed to contain a va...

Assume that s is a string variable that is supposed to contain a value to be converted to integer. Write a fragment of code that converts the value to integer variable and displ

The Generic Variable and Specific Variable, Explain difference, Generic Var...

Explain difference, Generic Variable: Create Object Ex:-Ole-Automation . No need refer the object library. What is Specific Variable: Binding Procedure Early & Late Binding ( Can

Mdi application - types of project using visual c++, MDI Application: ...

MDI Application: The MDI application utilizes the main frame window as the work space in which the user can open more document frame windows.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd