Advertisement
BlastFM

3_1 for

Apr 7th, 2021
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. package lab1;
  2.  
  3. import static java.lang.Math.*;
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class Lab3_1 {
  8.  
  9. public static void main(String[] args) {
  10.  
  11. double a,e,s1,s2;
  12. int L, M;
  13.  
  14. Scanner input = new Scanner(System.in);
  15.  
  16. System.out.print("L");
  17. L = input.nextInt();
  18.  
  19. System.out.print("M");
  20. M = input.nextInt();
  21.  
  22. System.out.print("a");
  23. a = input.nextDouble();
  24.  
  25. input.close();
  26.  
  27. e = 1.0;
  28. s1 = 0;
  29. s2 = 0;
  30. for (int k = 1; k<=M; k++) {
  31. e *= a * (pow(k,2)+1.0);
  32. s2 += (pow(k,2)/(a+1.0));
  33.  
  34. }
  35.  
  36. for(int j=1; j<=L; j++) {
  37.  
  38. s1 += ((j+2.0)/j);
  39. }
  40.  
  41.  
  42. System.out.print(e+s1-s2);
  43. }
  44.  
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement