aznishboy

Nathan's thing

Oct 2nd, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.53 KB | None | 0 0
  1. public class BadNews {
  2.  
  3.     public static void writeOdds() {
  4.         // print each odd number
  5.     int current = count;
  6.         for (int count = 1; count <= ((max_odd/2)+ 1); count++) {
  7.             System.out.print(current + " ");
  8.             current = (2 * count) + 1;
  9.         }
  10.     }
  11.  
  12.     public static void main(String[] args) {
  13.     int max_odd;
  14.         // write all odds up to 21
  15.     max_odd = 21;
  16.         writeOdds(max_odd);
  17.  
  18.         // now, write all odds up to 11
  19.         max_odd = 11;
  20.         writeOdds(max_odd);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment