fork download
  1. class Main {
  2. public static void main (String[] args) {
  3. for (int i : oddNumbers(2, 5)) System.out.println(i);
  4. }
  5.  
  6. public static int[] oddNumbers(int l, int r) {
  7. l += 1 - l % 2;
  8. r -= 1 - r % 2;
  9. int odd[] = new int[(r - l) / 2 + 1];
  10. for (int i = 0; i < odd.length; i++) odd[i] = l + (i * 2);
  11. return odd;
  12. }
  13. }
  14.  
  15. //https://pt.stackoverflow.com/q/225246/101
Success #stdin #stdout 0.06s 31984KB
stdin
Standard input is empty
stdout
3
5