You are on page 1of 2

Numero Perfecto

----------------------------------------------------------------------------
Dim n As Integer = TextBox1.Text
Dim sumatoria, r As Integer
For j = 1 To n
If n Mod j = 0 Then
sumatoria = sumatoria + j
End If
Next
r = sumatoria - n
If r = n Then
MsgBox(" es un numero perfecto")
Else
MsgBox(" no es un numero perfecto")
End If

_______________________________________________________________________
NUmero Primo
---------------------------------------------------------------
Dim n As Integer
Dim Cont As Integer = 0

Console.WriteLine("Este programa determina si un numero es Primo")


Console.WriteLine("-------------------------------------------..")

While True

Console.WriteLine("Ingrese el Numero: ")


n = (Console.ReadLine())

For i As Integer = 1 To n
If (n Mod i = 0) Then

Cont = Cont + 1
End If
Next

If (Cont <> 2) Then


Console.WriteLine("El numero NO es primo")

Else
Console.WriteLine("El numero es primo")

End If
Cont = 0
End While
___________________________________________________________________________________
_____
Factorial
-----------------------------------------------------------------------------------
--
Dim Fac As Long = 1
Dim n As Integer

Console.WriteLine("Este Programa Calcula el Factorial de un N�mero")


Console.WriteLine("------------------------------------------------------")
Console.WriteLine("Ingrese el Numero")
n = Console.ReadLine()
If (n >= 0) Then
For i As Integer = 1 To n
Fac = Fac * i
Next
Else
Console.WriteLine("No se aceptan numeros negativos")
Console.ReadLine()
End If
Console.WriteLine("El Factorial es: " & Fac)
Console.ReadLine()

You might also like