Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,104 questions

40,777 answers

573 users

How to find the factors of a number in VB.NET

Learn & Practice SQL


103 views
asked May 22, 2017 by avibootz
edited Aug 18, 2023 by avibootz

1 Answer

0 votes
' Numbers that divide the original number exactly
 
Imports System
 
Public Class AClass
    Public Shared Sub PrintFactors(n As Integer)
        For i As Integer = 1 To n
            If n Mod i = 0 Then
                Console.Write(i & " ")
            End If
        Next
    End Sub
    Public Shared Sub Main(ByVal args As String())
        Dim n As Integer = 100
        
        PrintFactors(n)
        
        Console.WriteLine()
        
        PrintFactors(24)
    End Sub
End Class
    
   
    
    
    
' run:
'
' 1 2 4 5 10 20 25 50 100 
' 1 2 3 4 6 8 12 24 
'

 

 





answered May 22, 2017 by avibootz
edited Aug 18, 2023 by avibootz
...