-
-
Save JorgeOlvera/7745887 to your computer and use it in GitHub Desktop.
Sum Program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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