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

Explain dtd elements and dtd attributes, Problem 1. Describe the concep...

Problem 1. Describe the concept of exception in .Net environment 2. Explain the process of adding, updating and deleting records with an example 3. Explain DTD elements a

C#, i want to print number following pattern 1 12 123 1234

i want to print number following pattern 1 12 123 1234

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

#tit, anumberisprimeornot

anumberisprimeornot

Deleting records - data control, Deleting Records: To remove a record ...

Deleting Records: To remove a record use the Delete method. To delete the record from the customer table follow the coding as shown below: data1.RecordSource = "Customer"

How to replace the text from textbox to another., I''m doing a project on v...

I''m doing a project on vb.NET. I''m stuck with this place where I should replace the text to different characters from textbox1 to textbox2 without changing text in textbox1. For

Vb script coding conventions, Coding conventions are recommended that may h...

Coding conventions are recommended that may help you write code via Microsoft Visual Basic Scripting Edition. Coding conventions can include the given: Naming conventions for ob

Program for computing automobile repair bills, A program is needed to assis...

A program is needed to assist computing automobile repair bills. The cost of labor is $35 per hour. The costs for parts are subject to a 5% sales tax, which should be added t

XML with database, write a XML with database with book details( book id, au...

write a XML with database with book details( book id, author ,subject, published year, vendor,price, language )

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