Welcome to collectivesolver - Programming & Software Q&A with code examples. A website you can trust. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il


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

Teach Your Child To Read

Dental Dog Chews
FRESH BREATHIES

GlucoTrust is a brand new, science-backed supplement that supports healthy blood sugar levels AND weight loss for men and women

Everything you need to sell anywhere

Managed VPS Hosting
Affordable. Secure. Your Own Virtual Private Hosting. Faster than AWS and Rackspace

Bonsai Boy of New York Bonsai Trees and Accessories
100%

Disclosure We are a professional Programming & Software Q&A website, that receives compensation from some of the links whose we show you with Information. It means that my content may contain affiliate links.

25,584 questions

33,347 answers

573 users

How to find all pythagorean triples (a^2 + b^2 = c^2) from an array in VB.NET

1 Answer

0 votes
Public Class Program
    Private Shared Sub PrintPythagoreanTriples(ByVal arr As Integer())
        Dim size As Integer = arr.Length

        For i As Integer = 0 To size - 2 - 1
            For j As Integer = i + 1 To size - 1 - 1
                For k As Integer = i + 2 To size - 1
                    Dim a As Integer = arr(i)
                    Dim b As Integer = arr(j)
                    Dim c As Integer = arr(k)

                    If a * a + b * b = c * c Then
                        Console.WriteLine(a & " " & b & " " & c)
                    End If
                Next
            Next
        Next
    End Sub

    Public Shared Sub Main(ByVal args As String())
        Dim arr As Integer() = New Integer() {2, 3, 4, 5, 6, 7, 8, 9, 10}

        PrintPythagoreanTriples(arr)
    End Sub
End Class




' run:
' 
' 3 4 5
' 6 8 10
'

 




answered 5 days ago by avibootz
edited 5 days ago by avibootz
...