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

XML document, Write a XML with database with book details (BOOK ID, Title, ...

Write a XML with database with book details (BOOK ID, Title, Author, subject, published Year, language, vendor, price)

Explain class module and standard module, Difference between Class Module a...

Difference between Class Module and Standard Module? Standard module: -This place for variable declarations,procedures etc.& it can accessed these procedures in whereve

Option explicit declaration - data types, Option Explicit Declaration: ...

Option Explicit Declaration: If the option explicit is used essentially then all the variables will have to be declared. Or else an error will be reported saying that the vari

Adding handlers with class wizard, Adding Handlers With Class Wizard: ...

Adding Handlers With Class Wizard: Whenever a handler is added, the class wizard places the prototype for the message handler in the header (.H) file. It gives a skeleton hand

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

Event-driven programming - windows programming, Event-Driven Programming: ...

Event-Driven Programming: The Event-driven programming allows the program to react to various inputs or events.   The action on a graphical component is an event. For il

Input box - dialogue box in visual basic , Input Box: To demonstrate t...

Input Box: To demonstrate the use of the Input Box as shown in figure. Now consider the illustration shown below: 1. Initiate a new project 2. Select the standard exe

Software with inappropriate behavior - basics of gui design, Software With ...

Software With Inappropriate Behavior: You would save a document; print it, and then you'll try to close it. The program will ask you if you want to save. This is because; the

Variant type - visual basic, Variant Type: If no data type is related ...

Variant Type: If no data type is related with the VB variables, it takes the default variant type. The variable x will be of the variant type when the two declarations below a

The frame - document view architecture, The Frame: As the name suggest...

The Frame: As the name suggests, the frame is a combination of the building blocks, structure and the borders of an item. The frame gives the "physical" presence to a window.

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