Exercise
Prime factors
Objetive
Write a Visual Basic (VB.Net) program that displays a number (entered by the user) as a product of its prime factors. For example, 60 = 2 · 2 · 3 · 5
(Hint: it can be easier if the solution is displayed as 60 = 2 · 2 · 3 · 5 · 1)
Code
Imports System
Public Class exercise63
Public Shared Sub Main()
Dim n As Integer
Dim d As Integer = 2
Console.Write("Enter the number: ")
n = Convert.ToInt32(Console.ReadLine())
While n > 1
While n Mod d = 0
Console.Write(d)
Console.Write(" · ")
n = n / d
End While
d += 1
End While
Console.Write(1)
End Sub
End Class