How to find the product of digits of a number in VB.NET

1 Answer

0 votes
Imports System

Public Class Program
    Public Shared Function get_product(ByVal n As Integer) As Integer
        Dim product As Integer = 1

        While n > 0
            Dim reminder As Integer = n Mod 10
            product = product * reminder
            n = n \ 10 ' \ not /
        End While

        Return product
    End Function

    Public Shared Sub Main()
        Console.WriteLine(get_product(32))
        Console.WriteLine(get_product(529))
    End Sub
End Class




' run:
'
' 6
' 90
'

 



answered Oct 8, 2021 by avibootz
...