aneliabogeva

Combinations

Nov 24th, 2020 (edited)
604
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class Combinations {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         Integer number = scanner.nextInt();
  7.         Integer counter = 0;
  8.  
  9.         for(int x1 = 0; x1 <= number; x1++){
  10.             for(int x2 = 0; x2 <= number; x2++){
  11.                 for(int x3 = 0; x3 <= number; x3++){
  12.                     if(x1+x2+x3 == number){
  13.                         counter+=1;
  14.                     }
  15.                     else{}
  16.                 }
  17.             }
  18.         }
  19.         System.out.println(counter);
  20.     }
  21. }
  22.  
RAW Paste Data