Skip to content

Instantly share code, notes, and snippets.

@imryan
Last active December 26, 2015 08:29
Show Gist options
  • Save imryan/7122504 to your computer and use it in GitHub Desktop.
Save imryan/7122504 to your computer and use it in GitHub Desktop.
Counts to 100, adding each number inclusively.
public class Count {
public static void main(String[] args)
{
// Declare variables
int i = 0;
int index = 0;
while (i != 100)
{
// Iterate i and add index to i, adding 1 each iteration
i++;
index += i;
}
// Output the final value
System.out.println("1 - 100 added inclusively: " + index);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment