Module Module1
Sub Main()
Dim n As Integer
Console.Write("Ingrese el número que desee evaluar: ")
n = Console.ReadLine
pi(n)
Console.ReadLine()
End Sub
Sub pi(ByVal x)
If x = 0 Then
Console.Write ("Par")
ElseIf x = 1 Then
Console.Write ("Impar")
Else
pi(x - 2)
End If
End Sub
End Module
Module Module1
Sub Main()
Dim a, c, b As Integer
Console.Write("Ingrese el 1º número: ")
a = Console.ReadLine
Console.Write("Ingrese el 2º número: ")
b = Console.ReadLine
c = b
Console.Write("El mcd es: ")
Console.Write(mcd(a, b, c))
Console.ReadLine()
End Sub
Function mcd(ByVal a, ByVal b, ByVal c)
If c = a Then
Return 0
Else
If (a Mod c = 0) And (b Mod c = 0) Then
Return c
Else
Return mcd(a, b, c - 1)
End If
End If
End Function
End module
Module module1
Sub main()
Dim x As Integer
Module module1
Sub main()
Dim n As Integer
Console.Write("Ingrese el número que desee evaluar: ")
n = Console.ReadLine
Console.Write(nd1(n))
Console.ReadLine()
End Sub
Function nd1(ByVal n)
Dim b As Integer
b = 0
Return nd2(n, b)
End Function
Function nd2(ByVal n, ByVal b)
If n = 0 Then
Return 1
Else
If n < 1 Then
Return b
Else
Return nd2(n / 10, b + 1)
End If
End If
End Function
End module
Suma de cuadrados
Module module1
Sub main()
Dim x As Integer
Console.Writeline(“ 1^2+2^2+3^2+... ... +n^2”)
Console.Write("Ingrese n: ")
x = Console.ReadLine
Console.Write("El resultado es: ")
Console.Write(cu(x))
Console.ReadLine ()
End Sub
Function cu(ByVal x)
If x = 1 Then Return 1
Return x ^ 2 + cu(x - 1)
End Function
End module
Module module1
Sub main()
Dim x As Integer
Console.Write("Ingrese el número que desee evaluar: ")
x = Console.ReadLine
Di(x)
Console.ReadLine()
End Sub
Sub di(ByVal x)
If x > 0 Then
Console.Writeline (" - " & x Mod 10)
x = Int(x / 10)
di(x)
End If
End Sub
End module
Module module1
Sub main()
Dim a, b As Integer
Console.Write("Ingrese el 1º número que desee evaluar: ")
a = Console.ReadLine
Console.Write("Ingrese el 2º número que desee evaluar: ")
b = Console.ReadLine
fc(a, b, b)
Console.ReadLine ()
End Sub
Sub fc(ByVal a, ByVal b, ByVal c)
If c <> 0 Then
If (a Mod c = 0) And (b Mod c = 0) Then
Console.Writeline (" - " & c)
fc(a, b, c - 1)
Else
fc(a, b, c - 1)
End If
End If
End Sub
End module
Potencia de un número
Module module1
Sub main()
Dim x, y As Integer
Console.Write("Ingrese la base: ")
x= Console.ReadLine
Console.Write("Ingrese el exponente: ")
y = Console.ReadLine
Console.Write( pot(x, y))
Console.ReadLine ()
End Sub
Function pot(ByVal x, ByVal y)
If y = 1 Then Return x
Return pot(x, y - 1) * x
End Function
End module
Module module1
Sub main()
Dim c, x, s As Integer
Console.Write("Ingrese La cantidad de numeros que desee evaluar:
")
x = Console.ReadLine
Dim ar(x) As Integer
For c = 1 To x
Console.Write("Ingrese " & c & "º numero: ")
Ar(c) = Console.ReadLine
s = s + ar(c)
Next
Console.Write("El promedio aritmetico es: ")
Console.Write(s / x)
Console.ReadLine()
End Sub
End Module
Module module1
Sub main()
Dim c, x, s As Integer
Console.Write("Ingrese La cantidad de numeros que desee evaluar:
")
x = Console.ReadLine
s = 1
Dim ar(x) As Integer
For c = 1 To x
Console.Write("Ingrese " & c & "º numero: ")
Ar(c) = Console.ReadLine
s = s * ar(c)
Next
Console.Write("El promedio geometrico es: ")
Console.Write(s ^ (1 / x))
Console.ReadLine()
End Sub
End Module
Module module1
Sub main()
Dim c, x As Integer
Dim s As Double
s = 0
Console.Write("Ingrese La cantidad de numeros que desee evaluar:
")
x = Console.ReadLine
Dim ar(x) As Integer
For c = 1 To x
Console.Write("Ingrese " & c & "º numero: ")
Ar(c) = Console.ReadLine
s = s + (1 / ar(c))
Next
Console.Write("El promedio Armonico es: ")
Console.Write(x / s)
Console.ReadLine()
End Sub
End Module
Module module1
Sub main()
Module module1
Sub main()
Dim c, x, s As Integer
Dim pert As Boolean
Pert = False
Console.Writeline("El array se rrellenara de forma aleatoria de 0
a 9 ")
End If
Next
Console.WriteLine()
If pert = False Then
Console.Writeline(s & " no pertenece al array")
ElseIf pert = True Then
Console.Writeline(s & " si pertenece al array")
End If
Console.ReadLine()
End Sub
End Module
End Sub
End Module