У меня есть следующий код
Код: Выделить всё
import javax.swing.*;
public class oddTest{
public static void odd(int a){
if (a < 0){
if (a % 2 != 0){
a++;
}
}
odd(--a);
}
public static void main(String[] args){
int n = 0;
String str = JOptionPane.showInputDialog(null, "make the limits = ");
n = Integer.parseInt(str);
odd(n);
JOptionPane.showInputDialog(n);
}
}
выход: 1, 3, 5, 7
Подробнее здесь: https://stackoverflow.com/questions/538 ... e-limits-n