Skip to content

Instantly share code, notes, and snippets.

@JorgeOlvera
Created December 2, 2013 06:28
Show Gist options
  • Save JorgeOlvera/7745887 to your computer and use it in GitHub Desktop.
Save JorgeOlvera/7745887 to your computer and use it in GitHub Desktop.
Sum Program
import java.util.Scanner;
public class sum2{
public static void main (String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Introduce an interger");
int limit = input.nextInt();
int nueva = 0;
int nueva2 = 0;
int triangular = limit * (limit+1)/2;
if (limit > 10000) {
System.out.println("Please introduce a smaller number");
}
else {
System.out.println(triangular);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment