tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
10
Task/Roots-of-unity/Java/roots-of-unity.java
Normal file
10
Task/Roots-of-unity/Java/roots-of-unity.java
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
public static void unity(int n){
|
||||
//all the way around the circle at even intervals
|
||||
for(double angle = 0;angle < 2 * Math.PI;angle += (2 * Math.PI) / n){
|
||||
double real = Math.cos(angle); //real axis is the x axis
|
||||
if(Math.abs(real) < 1.0E-3) real = 0.0; //get rid of annoying sci notation
|
||||
double imag = Math.sin(angle); //imaginary axis is the y axis
|
||||
if(Math.abs(imag) < 1.0E-3) imag = 0.0; //get rid of annoying sci notation
|
||||
System.out.print(real + " + " + imag + "i\t"); //tab-separated answers
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue