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

Develop web pages which use vbscript, In this unit you have learned how to ...

In this unit you have learned how to develop Web pages which use VBScript. You have learned to insert logic to your Web pages as along with any other programming application. You h

Do until loop statement , Do Until Loop Statement: The statements with...

Do Until Loop Statement: The statements within the do...until loop block executes till the condition given in until become true. The working of do...until loop is elaborated w

Collection is adding last record, Please help me.. I am loading data from ...

Please help me.. I am loading data from a text file to a class (Item Inventory from Tony Gaddis - Visual Basic - Chapter 12 -programming challange# 7-9) and the last item loaded is

Data types - visual basic, DATA TYPES   The different primitive data t...

DATA TYPES   The different primitive data types are Boolean, Char, Byte, Date, Decimal, Uinteger, Double, Integer, Long, Sbyte, Short, Single, String, Ulong & Ushort. To decla

Device context - visual c++, DEVICE CONTEXT The device context provides...

DEVICE CONTEXT The device context provides the essential drawing tools and the platform to draw. It helps to draw the text, shapes, lines etc. To create the device context, the

Adding records - data control, Adding Records: 1. As in the earlier ca...

Adding Records: 1. As in the earlier case Set the DatabaseName property as "C:\ex.mdb", now Set the Record Source for the data control as Customer and Set the Record Type to 0

Number property, Returns or sets a numeric value indicating an error. Numbe...

Returns or sets a numeric value indicating an error. Number is the Err object's default property. While returning user-defined error from an Automation object, set Err.Number throu

We are need of vb.net dynamically created gridview, We are need of VB.NET D...

We are need of VB.NET Dynamically Created Gridview with Textboxes, DDLs Utilizing VB code in ASP.NET I dynamically create a calendar showing either 3 or 6 or 9 or 12 months, dep

Source property, Returns or sets the name of the object or application whic...

Returns or sets the name of the object or application which generated the error originally. The Source property indicates a string expression which is usually the class name or pro

Dialog boxes in vb, DIALOG BOXES IN VB The two dialog boxes, namely, th...

DIALOG BOXES IN VB The two dialog boxes, namely, the message box and the input box are usually used in the Visual Basic. The message box is used for displaying the messages to

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