/* Hi with out sounding total thick! Here is the sum by Archimedes
i am trying to work out ,n = number of sides in a polygon.

He realized that the perimeter of a regular polygon of n sides inscribed
in a circle is smaller than the circumference of that circle and that
the perimeter of a regular polygon of n sides circumscribed around a
circle is greater than the circumference of that circle.

As n approaches infinity, the two perimeters approach the circumference,
In fact, one can think of a circle as a regular polygon with infinitely
many sides.

Using simple trigonometry, he showed that the perimeter of the
circumscribed polygon is 2nrsin(theta/2) and that the inscribed polygon
is 2nrtan (theta/2), where 0 is the angle subtended by any side of the
polygon at the centre (=360/n degrees). He concluded

n sin theta < PI < n tan theta
2 2


Now i have not do maths for 31 years now but i take this sum
to be the same as:

n sin 180 is less than PI and that PI is still less than n tan
I need to know how many sides for a polygon are needed to achieve this accuracy

So I want the computer to keep increasing the number of sides to achive
This accuracy

I need a loop to increase my sides by ++ till they reach this accuracy

The code I was given I can not get to won’t work
for (sides = 4; (Math.sin(Math.toRadians (sides)) <= Math.PI) + (Math.tan(Math.toRadians(sides)) >= Math.PI); sides++);

so I am still not getting any beauty sleep
*/

import java.math.*;
import java.io.*;
class ged1looptry
{
public static void main(String [] args)throws IOException
{
double sides = 4;
double n = (180/ sides);
double s = Math.sin(Math.toRadians(n));
double t = Math.tan (Math.toRadians(n));
double PI = 3.14592653589;
/*for (sides = 4; (Math.sin(Math.toRadians (sides)) <= Math.PI) + (Math.tan(Math.toRadians(sides)) >= Math.PI); sides++);*/
System.out.println("Sin ="+ s +" <=" + PI+ "<="+t );
}
}

// or am i working the maths wrong as well