Created
December 22, 2018 17:55
-
-
Save farhanpro/0bb7b36ce8aea01b4840785fcd939a10 to your computer and use it in GitHub Desktop.
Learned how to add the numbers from a loop
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
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