User Story
Write a code to check if the following list contains only ODD numbers.
List<Integer> numbers = new List<Integer>{1,3,5,7,9};
Expected Outcome
DEBUG | All the integers in the list are ODD
Code
List<Integer> numbers = new List<Integer>{1,3,5,7,9};
Boolean status = true;
for (Integer i : numbers) {
if (Math.mod(i,2) == 0){
status =false;
}
}
if(status==true){
System.debug('All the integers in the list are ODD');
}
else{
System.debug('There is at least one EVEN in the list');
}
Video
Video does not exists.