aneliabogeva

Combinations

Nov 24th, 2020 (edited)
618
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×