Advertisement
damesova

Combination [Mimi}

Apr 3rd, 2019
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Combination {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(scanner.nextLine());
  8.  
  9.         int counter = 0;
  10.  
  11.         for (int i = 0; i <= n; i++) {
  12.             for (int j = 0; j <= n; j++) {
  13.                 for (int k = 0; k <= n; k++) {
  14.                     for (int l = 0; l <= n; l++) {
  15.                         for (int m = 0; m <= n; m++) {
  16.                             if (i + j + k + l + m == n)
  17.                             counter++;
  18.                         }
  19.                     }
  20.                 }
  21.             }
  22.         }
  23.         System.out.println(counter);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement