5
1
An arithmetic sequence is a sequence of numbers of the form a,a+n,a+2n,a+3n, etc. In this case, a and n will both be either integers or decimals.
Given two inputs, a, n, and a top number value, return a list of numbers where the last term is less than or equal to the top number value.
The input can be formatted in any way, as well as the output.
The catch to this problem is dealing with floating point arithmetic errors.
For example, 0.1 + 0.3 * 3 is 1, however this will display 0.99999999999... if you simply go 0.1 + 0.3 * 3. We want 1, not 0.99999999999...
Test Cases
a=2, n=3, top=10: [2, 5, 8]
a=3, n=1.5, top=12: [3, 4.5, 6, 7.5, 9, 10.5, 12]
a=3.14159, n=2.71828, top=10: [3.14159, 5.85987, 8.57815]
a=0.1, n=0.3, top=2: [0.1, 0.4, 0.7, 1, 1.3, 1.6, 1.9]
Shortest code wins. Good luck!

Is this supposed to be a standalone program, or a function? If a standalone program is provided, are there any requirements to the format of the input or output? – breadbox – 2012-06-07T05:11:50.267
Function/standalone is fine. There is no specified input or output: the programmer will state both. – beary605 – 2012-06-07T05:49:45.240
1What do you mean by "floating points" in the first paragraph? If they're actual IEEE754 floating point numbers then most of your test cases don't make sense; so are they strings representing decimal floating point numbers? If so, to what precision? – Peter Taylor – 2012-06-07T09:33:44.287
I changed "floating points" to "decimals". – beary605 – 2012-06-07T15:53:51.467
The input/output part should be specified in the question, not just in the comments. – user unknown – 2012-06-08T13:41:32.617