Skip to content

Instantly share code, notes, and snippets.

@TranNgocMinh
Created February 4, 2018 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TranNgocMinh/1e6c7b9645856e2ba3697f27d1aeb33e to your computer and use it in GitHub Desktop.
Save TranNgocMinh/1e6c7b9645856e2ba3697f27d1aeb33e to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class ... {
public static void main(String[] args) {
int i, S = 0;
Scanner scanner = new Scanner( System.in );
System.out.print( "Nhap n = " );
int n = Integer.parseInt( scanner.nextLine() );
for(i =1; i<=n; i++)
S = S + i;
System.out.println("Tong la:" + S);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment