The Artima Developer Community
Sponsored Link

Java Buzz Forum
Happy PI Day

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Weiqi Gao

Posts: 1808
Nickname: weiqigao
Registered: Jun, 2003

Weiqi Gao is a Java programmer.
Happy PI Day Posted: Mar 14, 2006 1:58 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Weiqi Gao.
Original Post: Happy PI Day
Feed Title: Weiqi Gao's Weblog
Feed URL: http://www.weiqigao.com/blog/rss.xml
Feed Description: Sharing My Experience...
Latest Java Buzz Posts
Latest Java Buzz Posts by Weiqi Gao
Latest Posts From Weiqi Gao's Weblog

Advertisement

How could one miss this? It's PI day today. Here's a slow converging approximation of PI:

[weiqi@gao] $ cat PI.java
public class PI {
  public static void main(String[] args) {
    double sum = 0.0d;
    for (int i = 1; i < 64000; i++) {
      sum += 6.0/(i*i);
    }
    System.out.println(Math.sqrt(sum));
  }
}
[weiqi@gao] $ javac PI.java
[weiqi@gao] $ java PI
3.1415525815597167

Read: Happy PI Day

Topic: China Blocks SourceForge.net Previous Topic   Next Topic Topic: Pots and Kettles

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use