Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Omar Natour
- * 10/16/2015
- * Csc-111-D01
- * Problem 5.25
- * Compute the value of pie.
- */
- public class Homework5 {
- public static void main(String[] args) {
- for (int counter = 10000; counter <= 100000; counter += 10000) {
- System.out.print("value of pi when i = " + counter + " : ");
- double pie = 0;
- double div = 1;
- for (int i = 0; i < counter; i++) {
- if (i % 2 == 0)
- pie = pie + 1 / div;
- else
- pie = pie - 1 / div;
- div += 2;
- }
- System.out.println(pie * 4);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment