Professional Documents
Culture Documents
Dim n, i, s As Integer
n = TextBox1.Text
i = 1
'usamos el bucle
Do While i <= n
s = s + i
i = i + 1
Loop
TextBox2.Text = s
'factorial de un numero
Dim n, i, f As Integer
n = TextBox1.Text
i = 1
f = 1
'usamos el bucle
Do While i <= n
f = f * i
i = i + 1
Loop
TextBox2.Text = f
ni = TextBox1.Text
nf = TextBox2.Text
i = ni + 1
Do While i < nf
If i Mod 2 = 0 Then
c = c + 1
End If
i = i + 1
Loop
TextBox3.Text = c
n = TextBox1.Text
Do While n >= 1
d = n Mod 10
If d Mod 2 = 0 Then
c = c + 1
End If
n = n \ 10
Loop
TextBox2.Text = c
n = TextBox1.Text
Do While n >= 1
c = c + 1
n = n \ 10
Loop
TextBox2.Text = c
'dado un numero devolver el mayor digito
Dim n, mayor, d As Integer
n = TextBox1.Text
Do While n >= 1
d = n Mod 10
If d > mayor Then
mayor = d
End If
n = n \ 10
Loop
TextBox2.Text = mayor
'dado un numero devolver el numero invertido
Dim n, d, c As Integer
n = TextBox1.Text
Do While n >= 1
d = n Mod 10
c = c * 10 + d
n = n \ 10
Loop
TextBox2.Text = c
'determoinar si un numero es primo
Dim n, i, c As Integer
Dim r As String
n = TextBox1.Text
i = 1
Do While i <= n
If (n Mod i) = 0 Then
c = c + 1
End If
i = i + 1
Loop
If c = 2 Or n = 1 Then
r = "es primo"
Else
r = "no es primo"
End If
TextBox2.Text = r
n1 = TextBox1.Text
n2 = TextBox2.Text
n3 = TextBox3.Text
If n1 > n2 Then
n1 = aux
n1 = n2
n2 = aux
End If
If n1 > n3 Then
n1 = aux
n1 = n3
n3 = aux
End If
If n2 > n3 Then
n2 = aux
n2 = n3
n3 = aux
End If
TextBox4.Text = n1
TextBox5.Text = n2
TextBox6.Text = n3
'ordenar 4 numeros
Dim n1, n2, n3, aux, n4 As Integer
n1 = TextBox1.Text
n2 = TextBox2.Text
n3 = TextBox3.Text
n4 = TextBox4.Text
If n1 > n2 Then
aux = n1
n1 = n2
n2 = aux
End If
If n1 > n3 Then
aux = n1
n1 = n3
n3 = aux
End If
If n1 > n4 Then
aux = n1
n1 = n4
n4 = aux
End If
If n2 > n3 Then
aux = n2
n2 = n3
n3 = aux
End If
If n2 > n4 Then
aux = n2
n2 = n4
n4 = aux
End If
If n3 > n4 Then
aux = n3
n3 = n4
n4 = aux
End If
TextBox5.Text = n1
TextBox6.Text = n2
TextBox7.Text = n3
TextBox8.Text = n4
'ordenar 5 numeros
Dim n1, n2, n3, aux, n4, n5 As Integer
n1 = TextBox1.Text
n2 = TextBox2.Text
n3 = TextBox3.Text
n4 = TextBox4.Text
n5 = TextBox5.Text
If n1 > n2 Then
aux = n1
n1 = n2
n2 = aux
End If
If n1 > n3 Then
aux = n1
n1 = n3
n3 = aux
End If
If n1 > n4 Then
aux = n1
n1 = n4
n4 = aux
End If
If n1 > n5 Then
aux = n1
n1 = n5
n5 = aux
End If
If n2 > n3 Then
aux = n2
n2 = n3
n3 = aux
End If
If n2 > n4 Then
aux = n2
n2 = n4
n4 = aux
End If
If n2 > n5 Then
aux = n2
n2 = n5
n5 = aux
End If
If n3 > n4 Then
aux = n3
n3 = n4
n4 = aux
End If
If n3 > n5 Then
aux = n3
n3 = n5
n5 = aux
End If
If n4 > n5 Then
aux = n4
n4 = n5
n5 = aux
End If
TextBox6.Text = n1
TextBox7.Text = n2
TextBox8.Text = n3
TextBox9.Text = n4
TextBox10.Text = n5