Encontrar Primos

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

1 Encontrar los primos menores a X.

Diseo y salida del formulario

Bisual Basic Net 2008 2010


Public Class Form1 ''funcin para encontrar primos menores a x. Private Sub LlenarVector(ByVal x As Integer) Dim r, div As Integer LsBPrimos.Items.Clear() r = 1 While r <= x For i = 1 To r If r Mod i = 0 Then div = div + 1 End If Next If div <= 2 Then LsBPrimos.Items.Add(r) End If div = 0 r = r + 1 End While End Sub Private Sub BtnList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnList.Click Dim x As Integer x = Val(TxtX.Text) LlenarVector(x) End Sub End Class

You might also like