Created with <3 with dartpad.dev.
Last active
October 7, 2022 04:16
-
-
Save oriohac/a041f76289ef3a9b3db50bdea9b524d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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