Posts Tagged ‘javaSE’

Pythagorean triplet

Find the only Pythagorean triplet (a, b, c), for which a + b + c = 1000?

Here Pythagorean triplet means a2 +b2=c2

In order to find the triplet which satisfies the given criteria, we have to consider  the following rules


hence c=1000-a-b


3<a<1000/3   (a<b<c)


Here is the working java code
[soucecode language=”java”]

* @author Vasanth Raja Chittampally

public class Main {

public static void main(String[] args) {

out:for (int i = 1; i <1000/3; i++) {
for (int j = 1; j < 1000/2; j++) {
int k=(1000-i-j);
System.out.println(i+” “+j+” “+k);
break out;





JavaProgram…. Mail it!!!


All the programming freaks, you find this post very interesting. Here is the program to send a mail using javamail API.

The JavaMail API requires JDK/JRE 1.4 or higher. The JavaMail API is a Java optional package, it is not part of the core Java SE but is included in Java EE.

The above java code requires two other jar files, activation.jar and mail.jar which are to be kept inside the dist folder when working with any IDE such as NetBeans, Or else  these files are to be set in the environmental variables path. Here is the javamail API download link.

Here is the Fundamentals of the JavaMail API.