Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Java >> Snippet

Repeat code every n counts


int n = 5     //set n to be whatever value you choose

for ( int number = 0 ; number < 1000 ; number ++ ) {
   if (number % n == 0) System.out.println( "#: " + number) ;
   // prints all numbers evenly divisible by n
}