Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class calctri {
- public static void main(String[] args) {
- int a; //Zahl 1
- int b; //Zahl 2
- int c; //Zahl 3
- int max=2012; //Maximale Zahl
- int s; //Summe der Zahlen a+b+c
- long n=0L; //Anzahl
- for (a=0; a <= max; a++) {
- //System.out.println(a);
- for (b=a+1; b<=max; b++) {
- //System.out.println("a="+a+" b="+b);
- for (c=b+1; c<=max; c++) {
- //System.out.println("a="+a+" b="+b+" c="+c);
- s = a+b+c;
- if (s%3 == 0) {
- n=n+1;
- System.out.println("a="+a+" b="+b+" c="+c);
- //System.out.println("DEBUG!! "+n);
- } //end of if
- } //end of for-loop c
- } //end of for-loop b
- } //end of for-loop a
- System.out.println("Die Anzahl der Tripel beträgt: "+n);
- } //end of main
- } //end of class calctri
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement