[Programming Challenge] #1 - Print numbers
Out of boredom I've decided to timely post programming challenges/puzzles, probably mainly minimalist, to promote programming activity in LG.
There's already a few posted here by Artificial, but I've yet to allocate the time to have a crack at them. I plan on eventually trying my hand at it, though.
Alright, here's the challenge criteria:
-Define a procedure that [1]strictly takes as input an even [2]natural number (n) and from 1 prints all numbers that n consists of. (e.g. Supplying 4 in the procedure should sequentially print all numbers from 1 to 4.)
Subjective difficulty: Extremely easy
Post your code in this thread (preferably enclosed in [spoiler] tags by convention).
No deadline. Feel free to do this anytime.
Any programming language of your choice can be used.
I implore anyone to try to solve these given problems whenever you can.
Now, rev up those engines!
Superscript explanations:
[1]By strictly I mean submissions have to follow every specification made. The main processing has to begin with an even natural number. If the input is not an even natural number, you have to be the one to programmatically determine such and act on that.
[2]A natural number by definition is 1 or any repetition of it (¹ - ∞). That means pretty much any number above 1.
My solution in Python:
Note: Plagiarism is not tolerated. I also do not recommend looking at the code in the spoiler (or at least until you're sure you've completed the challenge), as it could contain all kinds of hidden factories (including an invalid solution and/or watermarks). The purpose of a challenge is for an intellectually stimulating challenge, not a false sense of self-gratification.
Edit: This is sort of the wrong section, so if a staff member would be so kind as to move it to the appropriate section, it would be greatly appreciated.