Possible pairs forming a Pythagorean Triple with a given value | C # program to compute all the possible pairs that forms a pythagorean triple with a given value ; Function to generate all possible pairs ; List to store all the possible pairs ; Checking all the possible pair in the range of [ 1 , c ) ; If the pair satisfies the condition push it in the vector ; Driver code ; If no valid pair exist ; Print all valid pairs
using System ; using System . Collections . Generic ; class GFG { class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static List < pair > Pairs ( int C ) { List < pair > ans = new List < pair > ( ) ; for ( int i = 1 ; i < C ; i ++ ) { for ( int j = i + 1 ; j < C ; j ++ ) { if ( ( i * i ) + ( j * j ) == ( C * C ) ) { ans . Add ( new pair ( i , j ) ) ; } } } return ans ; } public static void Main ( String [ ] args ) { int C = 13 ; List < pair > ans = Pairs ( C ) ; if ( ans . Count == 0 ) { Console . Write ( " No ▁ valid ▁ pair ▁ " + " exist " + " STRNEWLINE " ) ; return ; } foreach ( pair i in ans ) { Console . Write ( " ( " + i . first + " , ▁ " + i . second + " ) " + " STRNEWLINE " ) ; } } }