109k views
0 votes
Create a list of the odd numbers between 1 and n (include 1 as well as n -- if it's odd-- in the list). Associate the list with the variable odds.

1 Answer

5 votes
The odd numbers can be generated by adding 2 to the first odd number.

Starting with 1 as the first odd number, you get 1, 3, 5, 7, 9, ...

A general formula to name the odd numbers is 2n + 1, where n can take any whole value.

Look:

n 2n + 1

0 0+1 = 1
1 2(1) + 1 = 2 + 1 = 3
2 2(2) + 1 = 4+1 = 5
3 3(2) + 1 = 6 + 1 = 7
4 4(2) + 1 = 8 + 1 = 9.

So, you now can use the general formula 2n + 1 to generate any odd number, starting with n = 0 to generate the first odd number, 1.
User Nick Gerakines
by
9.3k points