answersLogoWhite

0


Best Answer

A Pythagorean triplet is the set of three integers such that:

a < b < c and a2 + b2 = c2

private static final void printPythag(final int max) {

for (int a = 1; a < max; ++a) {

for (int b = a + 1; b < max; ++b) {

final double possibleValueOfC = Math.sqrt(a * a + b * b);

// (ugly) Check to see if the result was an integer.

// If so, we have a Pythagorean triple on our hands.

if (possibleValueOfC == (double) ((int) possibleValueOfC)) {

System.out.println("(" + a + "," + b + "," + (int) possibleValueOfC + ")");

}

}

}

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Java program to print Phythagorean triplets?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is java program on computers?

#!/usr/bin/perl print 'java program';


What is java console?

The Java console is a display of output sent by a Java program. This is similar to the MS DOS operating system.To print to the console, a programmer will type "println(text);" or "print(text);" depending is the programmer wants to make a new line after the text(println) or not(print).


Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


What do you mean by multithread program in java?

A Program in Java that spawns multiple threads is called a multithreaded program in Java.


How do you construct a java program that print table with backslash?

within inverted commas using two backslashes consequently .. we will print the backslash. ex: printf("//n it will gives output");


In a java program in a return statement with string concatenation how do you print a blank line?

use "\n" between the words where you want a new line


What is java virtucal mechine?

That refers to the program that runs the compiled Java program.


What powder game doesnt need java?

Any program written for the Java technology needs Java. Any program NOT written for Java DOESN'T need it.


Java Track?

Java Track is the java training program offered by SynergisticIT


How can you print a table of 5 in java by getting values from user?

look at the print


Where can one get the program Java?

The program Java can be downloaded from the official Java website on the internet. The program is free for personal use, so it can be downloaded without any cost by anyone.


What is a Java applet?

PCH answer small Embedded Java Program.