Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 30th, 2012  |  syntax: Java  |  size: 0.50 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public class PiBerechnenAnwendung {
  2.  
  3.         public static void main(String args[]){
  4.                 int k = 1000;
  5.                 System.out.printf("%1.15f\n", rekursion(k));
  6.         }  
  7.        
  8.         private static double rekursion(int tiefe) {
  9.                 if (tiefe >= 0) {
  10.                         return ( (1/Math.pow(16,tiefe))*( (4/(8*(double)tiefe+1)) - (2/(8*(double)tiefe+4)) - (1/(8*(double)tiefe+5)) - (1/(8*(double)tiefe+6)) ) + rekursion(tiefe-1) ) ;
  11.                 } else {
  12.                         return 0;
  13.                 }
  14.         }
  15. }