Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. int Chisl, Znam, I, N;
  5. double Sum;
  6. System.out.println("Введте значение N");
  7. Scanner num_N = new Scanner(System.in);
  8. int N = num_N.nextInt();
  9. Sum = (0.5);
  10. Chisl = 1;
  11. Znam = 2;
  12. for ( I = 2; I <= N; I++) {
  13. Znam = Znam * 2;
  14. Sum = Sum + (Chisl / Znam);
  15. }
  16. } System.out.println("Sum = "+Sum);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement