Skip to content

Instantly share code, notes, and snippets.

@farhanpro
Created December 22, 2018 17:55
Show Gist options
  • Save farhanpro/0bb7b36ce8aea01b4840785fcd939a10 to your computer and use it in GitHub Desktop.
Save farhanpro/0bb7b36ce8aea01b4840785fcd939a10 to your computer and use it in GitHub Desktop.
Learned how to add the numbers from a loop
package com.company;
public class Main {
public static void main(String[] args) {
int count =0;
int sum =0;
for (int number = 1; number < 1000;number++) {
if(number%3==0&&number%5==0){
// System.out.println(number+number);
System.out.println("Found : "+number);
sum=sum+number;
count++;
}
if(count==5){
break;
}
}
System.out.println("Additon of all above numbers : "+sum);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment