Answered step by step
Verified Expert Solution
Question
1 Approved Answer
make sure it's in JAVA Write a program that will find the value of PI iteratively. Print the number of iterations and the seconds it
make sure it's in JAVA
Write a program that will find the value of PI iteratively. Print the number of iterations and the seconds it took to find the result. You should be able to change the number of iterations. (More iterations will take more time to calculate obviously) PI=3.1415922535897423 after 2500000 iterations It took 0.021 seconds to complete this operation You can use any algorithm you like as long as it is an iterative algorithm. The most well-known one is the Leibniz formula for PI. 1 - 1/3 + 1/5 - 1/7 + 1/9 - ... = pi/4. Using summation notation: sigma^infinity_n=0 (-1)^n/2n + 1 = pi/4. For calculating the time, you can use System.nanoTime() method. We had an example of it in the Repetition.java program in the instructor's lecture contentStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started