0% found this document useful (0 votes)
116 views3 pages

Write A VB Program (Visual Basic 6.0) Code For Find Fibonacci Series

This document contains 3 code snippets in Visual Basic for: 1. Calculating the Fibonacci series up to a given number 2. Calculating the first n prime numbers 3. Calculating the first n prime numbers with a more detailed code sample and explanation

Uploaded by

juan olivera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views3 pages

Write A VB Program (Visual Basic 6.0) Code For Find Fibonacci Series

This document contains 3 code snippets in Visual Basic for: 1. Calculating the Fibonacci series up to a given number 2. Calculating the first n prime numbers 3. Calculating the first n prime numbers with a more detailed code sample and explanation

Uploaded by

juan olivera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

public class....

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


Dim a As Integer, b As Integer, n As Integer
a=0:b=1
Dim c As Integer, suma As Integer = 0
n = CInt(InputBox("digite", "digite"))
Dim i As Integer
For i = 0 To n - 2
suma = suma + b
c=a+b
a=b
b=c
Next
TextBox1.Text = suma
End Sub
End Class

Write a vb program (visual basic 6.0) code for


find Fibonacci series:-

Private Sub Command1_Click()


Dim x, g, n, i, sum As Integer
n = Val(Text1.Text)
x=0
y=1
Print x
Print y
For i = 3 To n
sum = x + y
Print sum
x=y
y = sum
y = sum
Next i

End Sub
Calcular los n primeros números primos Codigo Fuente en Visual Basic

Problema

Calcular los n primeros números primos

Solución

Ingresamos un número decimal donde se indica la cantidad de números primos que se desea
obtener

Ejemplo
Entrada: 5

Salida: 2 3 5 7 11

Codigo Fuente en Visual Basic

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles Button1.Click

Dim num As Integer

Dim n As Integer = 4

Dim cont As Integer = 2

Dim i As Integer

Dim cad As String = ""

num = TextBox1.Text

If (num > 2) Then

cad = "2 - 3"

While (cont < num)

i=2

While (i <= n)

If (i = n) Then

cad = cad + " - " + Trim(n)

cont = cont + 1

Else

If (n Mod i = 0) Then

i=n

End If

End If

i=i+1
End While

n=n+1

End While

TextBox2.Text = cad

Else

If (num > 0) Then

If (num = 1) Then

TextBox2.Text = "es primo 2"

Else

TextBox2.Text = "Es primo 2, 3"

End If

Else

TextBox2.Text = "ingrese un numero positivo"

End If

End If

End Sub

End Class

You might also like