Bài 1
unknown
java
2 years ago
332 B
12
Indexable
import java.util.Scanner;
public class P1 {
public static int Sol(int n) {
int s = 0;
for (int i = 1; i <= n; i++)
s += i;
return s;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
System.out.println("S(" + n + ") = " + Sol(n));
}
}
Editor is loading...
Leave a Comment