Created
          August 12, 2015 16:50 
        
      - 
      
 - 
        
Save nraychaudhuri/377ca198b491145147b3 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | private void busy(FiniteDuration duration) { | |
| pi(duration.toMillis() * 800); | |
| } | |
| private BigDecimal pi(long m) { | |
| int n = 0; | |
| BigDecimal acc = new BigDecimal(0.0); | |
| while(n < m) { | |
| acc = acc.add(gregoryLeibnitz(n)); | |
| n += 1; | |
| } | |
| return acc; | |
| } | |
| private BigDecimal gregoryLeibnitz(int n) { | |
| return new BigDecimal(4.0 * (1 - (n % 2) * 2) / (n * 2 + 1)); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment