Skip to content

Instantly share code, notes, and snippets.

@User0111
Created January 11, 2017 15:35
Show Gist options
  • Save User0111/2f62518a48a4c2523b147b9d85a2c455 to your computer and use it in GitHub Desktop.
Save User0111/2f62518a48a4c2523b147b9d85a2c455 to your computer and use it in GitHub Desktop.
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int sum = 0;
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
for(int i=0;i<=n;i++){
sum = sum + i;
}
System.out.println("Сума арифметичного ряду від 0 до " + n +" = "+sum);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment