Skip to content

Instantly share code, notes, and snippets.

@FreeFly19
Forked from User0111/homeWork2(7*)
Created January 15, 2017 00:54
Show Gist options
  • Save FreeFly19/30d271e6c8ee2fcbefd008b790d3e2c1 to your computer and use it in GitHub Desktop.
Save FreeFly19/30d271e6c8ee2fcbefd008b790d3e2c1 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) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int sum = 0;
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