public class Main{
public int[] arrayOfOdds(int highestValue) {
int variable = highestValue / 2 + highestValue % 2;
//if (highestValue % 2 == 0){
// variable = highestValue / 2;
//}
//else{
// variable = highestValue / 2 + 1;
//}
int [] oddArray = new int[variable];
System.out.println(oddArray.length);
for(int i = 0; i < variable; i++){
oddArray[i] = 2*i+1;
}
return oddArray;
}
public static void main(String[] args){
Main tester = new Main();
int[] array1 = tester.arrayOfOdds(30);
int[] array2 = tester.arrayOfOdds(25);
for(int i = 0; i < array1.length; i++){
System.out.print("(" + array1[i] + ")");
}
System.out.println();
for (int i = 0; i < array2.length; i++){
System.out.print("(" + array2[i] + ")");
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: