Anonymous user
Lucky and even lucky numbers: Difference between revisions
m
trying to tidy up the task description
(J) |
m (trying to tidy up the task description) |
||
Line 1:
{{draft task}}
''[[wp:Lucky number|Lucky numbers]]'' are positive integers that are formed by:▼
▲''Lucky numbers'' are positive integers that are formed by:
▲* Form a list of all the positive odd integers > 0<br><math>1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39 ...</math>
#*
▲* (Loop begins here)
▲:* Note then return the second number from the list (which is '''3''').
#* Note then return the third number from the list (which is '''7''').
▲:* Discard every third, (as noted), number from the list to form the new list<br><math>1, 3, 7, 9, 13, 15, 19, 21, 25, 27, 31, 33, 37, 39, 43, 45, 49, 51, 55, 57 ...</math>
▲:* <small>(Expanding the loop a few more times...)</small>
▲:* Discard every 9<sup>th</sup>, (as noted), number from the list to form the new list<br><math>1, 3, 7, 9, 13, 15, 21, 25, 31, 33, 37, 43, 45, 49, 51, 55, 63, 67, 69, 73 ...</math>
# <small>(Rule for the loop)</small>
▲:* Take the 7<sup>th</sup>, i.e. '''21'''. Remove every 21<sup>th</sup>.
#* Remove every <math>m</math><sup>th</sup>.
#* Increment <math>n</math>.
'''Definition of even lucky numbers'''▼
This follows the same rules as the definition of lucky numbers above ''except for the very first step'':
# <small>(Rule for the loop)</small>
#* Remove every <math>m</math><sup>th</sup>.
#* Increment <math>n</math>.
*
*
* The command line handling should:
** support mixed case handling of the (non-numeric) arguments
* The resulting list of numbers should be printed on a single line.
▲'''task requirements'''
▲* write one or two subroutines (functions) to generate ''lucky numbers'' and ''even lucky numbers''
▲* since input is from the command line, tests should be made for the common errors
▲::* missing arguments
▲::* too many arguments
▲::* number (or numbers) aren't legal
▲::* misspelled argument ('''lucky''' or '''evenLucky''')
▲::* support for a particular number
▲::* support for a range of particular numbers
▲::* support for a range of values
▲<br>The program should support the arguments:
<pre>
what is displayed (on a single line)
Line 74:
where |k| is the absolute value of k
</pre>
Demonstrate the program by:
*
*
*
*
*
*
;See also:
Line 89 ⟶ 88:
* Sequence [https://oeis.org/A045954 A045954 even lucky numbers or ELN] on The On-Line Encyclopedia of Integer Sequences.
* Entry [http://mathworld.wolfram.com/LuckyNumber.html lucky numbers] on The Eric Weisstein's World of Mathematics.
=={{header|J}}==
|