Skip to content

Instantly share code, notes, and snippets.

@oriohac
Last active October 7, 2022 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oriohac/a041f76289ef3a9b3db50bdea9b524d6 to your computer and use it in GitHub Desktop.
Save oriohac/a041f76289ef3a9b3db50bdea9b524d6 to your computer and use it in GitHub Desktop.
void main() {
oddNumbers();
}
oddNumbers(){
for(var i = 1; i <= 30; i++){
if(i%2 != 0){
print(i);
/*The output are odd numbers ranging from 1 to 29, as we print the
integers in the integer variable i whose modulo answer after being divided
by 2 is not equal to 0, which satisfies the properties of an odd number.
*/
}
if(i == 30){
print("The number is at $i\n");
/* The output will be a string 'The number is at 30' since we
are printing variable i if i is equal to 30 in the while loop.
The \n escape sequence ensures the next output starts on a new line.
*/
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment