Advertisement
Guest User

Untitled

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