Pages

Search This Blog

Calculate Factorial of a given number using For-loop


Module Factorial_ForLoop
    Sub main()
        Dim n, i, f As Integer
        Console.Write("Enter a Number: ")
        n = CInt(Console.ReadLine())
        f = 1
        If n < 0 Then
            Console.WriteLine("Factorial of negative number is not possible")
        ElseIf n = 0 Or n = 1 Then
            Console.WriteLine("Factorial of " + n.ToString() + " is 1")
        Else
            For i = 1 To n
                f *= i
            Next
            Console.WriteLine("Factorial of " + n.ToString() + " is " + f.ToString())
        End If
        Console.ReadLine()
    End Sub
End Module

25 comments:

  1. HAHA nice meme 88)))))

    ReplyDelete
  2. VB.net codings with example

    ReplyDelete
  3. i tried this code and it's running, thank you

    ReplyDelete
  4. Good Post! Thank you so much for sharing this pretty post,
    it was so good to read and useful to improve my knowledge as updated one, keep blogging.

    Java training in Chennai

    Java training in Bangalore

    Java online training

    Java training in Pune

    ReplyDelete
  5. click here formore info.
    .....................................................................

    ReplyDelete
  6. AEF05Alondra1D44014 April 2024 at 04:52

    04F5E
    ----
    ----
    matadorbet
    ----
    ----
    ----
    ----
    ----
    ----

    ReplyDelete