Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Task3 {
- public static void main(String[] args) {
- Scanner sc =new Scanner(System.in);
- int countBox=Integer.parseInt(sc.nextLine());
- int k=1;
- int smallestBox=1;
- smallestBox =k;
- int nextOne =k*(k+1);
- int countOrange=0;
- int countApple=0;
- for (int i=0;i<=countBox;i++){
- if(i%2==0){
- countOrange+=nextOne;
- }
- if(i%2!=0){
- countApple+=smallestBox;
- }
- }
- System.out.println(Math.abs(countOrange-countApple));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement