CSES - E4590 2018 0 - Results
Submission details
Task:Loops
Sender:jeroenrobben
Submission time:2018-09-13 00:29:36 +0300
Language:Java
Status:COMPILE ERROR

Compiler report

input/loops.java:3: error: class Main2 is public, should be declared in a file named Main2.java
public class Main2 {
       ^
1 error

Code

import java.util.Scanner;

public class Main2 {

	public static void main(String[] args) {
		
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();	   
	    System.out.println(calculate(n));
	    scan.close();

	}
	
	public static long calculate(int n) {
		return (long) ( (Math.pow(n, 3) / 6.0 ) + (Math.pow(n, 2) / 2.0 ) + ( n/ 3.0 ) );
	
	}
}