gabelkova123 / lab

0 stars 0 forks source link

lab3_2 #6

Closed gabelkova123 closed 1 year ago

gabelkova123 commented 1 year ago

package Lab3;

public class Task_2 { public static void main(String[] args){ double sum = 1; for (int i=2;i<=10000;i++){ if (i%2 ==0){ System.out.print(Math.pow(i,-1)+"минус"); sum-=Math.pow(i,-1); } else { System.out.print(Math.pow(i,-1)+"плюс"); sum+=Math.pow(i,-1);

        }
    }
    System.out.print(sum);
}

}