Executando verificação de segurança...
Em resposta a [Não disponível]
2
Module Module1
    Sub Main()
        For i As Integer = 0 To 1000
            If IsCousin(i) Then
                Console.WriteLine(i & " is a cousin number.")
            Else
                Console.WriteLine(i & " is divided by " & GetDivisors(i))
            End If
        Next
        Console.ReadLine()
    End Sub

    Function IsCousin(ByVal n As Integer) As Boolean
        If n < 2 Then
            Return False
        End If
        For i As Integer = 2 To Math.Sqrt(n)
            If n Mod i = 0 Then
                Return False
            End If
        Next
        Return True
    End Function

    Function GetDivisors(ByVal n As Integer) As String
        Dim divisors As String = ""
        For i As Integer = 1 To n
            If n Mod i = 0 Then
                divisors &= i & ", "
            End If
        Next
        Return divisors.Substring(0, divisors.Length - 2)
    End Function
End Module
Carregando publicação patrocinada...