chillurbrain

Task2

Sep 22nd, 2015
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.34 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Task2
  4. {
  5.     public static void main(String[] args)
  6.     {
  7.         Scanner sc = new Scanner(System.in);
  8.         int num = sc.nextInt();
  9.         int result = 0;
  10.         for (int i = 0; i <=num; i++)
  11.         {
  12.             result += (i-1)*i;
  13.         }
  14.         System.out.println(result);
  15.     }    
  16. }
Advertisement
Add Comment
Please, Sign In to add comment