Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2014
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. public class Tupel2
  2. {  
  3.     public static String tupelfinden(double maxgrenze)
  4.     {
  5.         double a;
  6.         double b;
  7.         double c;
  8.         double cSumme =0;
  9.         double bmin;
  10.         double bmax;
  11.         double aDifferenz;
  12.         String ergebnis ="";          
  13.        
  14.           bmax = Math.ceil(Math.cbrt(maxgrenze*maxgrenze));
  15.           for(b = 1; b <= bmax ;b++)
  16.              {
  17.                 a =1;
  18.                 do
  19.                  {                                
  20.                     cSumme = a*a*a +b*b*b;
  21.                     c = Math.sqrt(cSumme);
  22.                     a++;
  23.                                        
  24.                     if(c == (long)c && c*c <=maxgrenze*maxgrenze)
  25.                     {
  26.                      ergebnis = "\n\t( " + (a-1) + "," + b + "," + c + " )\n";            
  27.                      System.out.println("(" + (a-1) + ", " + b + ", " + c + ")");
  28.                    
  29.                     }
  30.                 }while(a<=b);          
  31.     }
  32.  return(ergebnis);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement