fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main
  4. {
  5. public static void main (String[] args)
  6. {
  7. int n, powOf2 = 1;
  8. double x, sum = 0;
  9. Scanner scanner = new Scanner(System.in);
  10.  
  11. n = scanner.nextInt();
  12. x = scanner.nextDouble();
  13.  
  14. for (int i = 1; i <= n; i++)
  15. {
  16. powOf2 *= 2;
  17. sum += Math.sin(i*x)/powOf2;
  18. }
  19.  
  20. System.out.println(sum);
  21. }
  22. }
Success #stdin #stdout 0.12s 2841600KB
stdin
10
-2.3
stdout
-0.1944212191294577