Skip to content

Commit

Permalink
Merge pull request #5254 from devjonramos/main
Browse files Browse the repository at this point in the history
Reto #39 - Java
  • Loading branch information
kontroldev authored Oct 7, 2023
2 parents 2f52de6 + cbd05e9 commit 2971e22
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import java.util.ArrayList;
import java.util.List;

public class DevJonRamos {

public static List<List<Integer>> triplesPitagoricos(int limite){

int m = 2;
List<List<Integer>> ternas = new ArrayList<>();

while (true) {

for (int n = 1; n < m; n++) {

int a = (m * m) - (n * n);
int b = 2 * m * n;
int c = (m * m) + (n * n);

if(c > limite) return ternas;

ternas.add(List.of(a, b, c));

}

m++;

}

}

public static void main(String[] args) throws Exception {

int limite = 50;

System.out.println(triplesPitagoricos(limite));

}
}

0 comments on commit 2971e22

Please sign in to comment.