Entry 53412

FActorial

   

Submitted by anonymous on Aug. 8, 2012 at 5:50 p.m.
Language: VB.net. Code size: 717 bytes.

Module Module1

    Sub Main()
        Dim n, fact, t As Integer
        Console.Write("Enter a Number:")
        n = CInt(Console.ReadLine())
        Console.WriteLine("Given Number= " + n.ToString())
        t = n
        fact = 1
        If n < 0 Then
            Console.WriteLine("No factorial for negative number")
        ElseIf n = 0 Or n = 1 Then
            Console.WriteLine("Factorial of " + n.ToString() + "is 1")
        Else

            While n > 0
                fact *= n
                n -= 1
            End While
            Console.WriteLine("Factorial of " + t.ToString() + "=" + fact.ToString())

        End If
        Console.ReadLine()

    End Sub

End Module

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).