Skip to content

Instantly share code, notes, and snippets.

@rehashedprime
Created October 19, 2019 15:36
Show Gist options
  • Save rehashedprime/fea7e8b140f7a2714a6b9ee546f25c3e to your computer and use it in GitHub Desktop.
Save rehashedprime/fea7e8b140f7a2714a6b9ee546f25c3e to your computer and use it in GitHub Desktop.
TEST.JAVA
public class test {
public static int sum( int i1, i2) {
int result = 0;
for (int i=i1; i<= i2; i++)
result += i;
return result;
}
public static void main ( String [] args){
System.out.println("Sum from 1 to 10 is " + sum(1, 10));
System.out.println("Sum from 20 to 37 is " + sum(20, 37));
System.out.println("Sum from 35 to 49 is " + sum(35, 49));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment