Basic Pascal Tutorial/Chapter 3/Programming Assignment: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | 3E - Programming Assignments (author: Tao Yue, state: unchanged) | |
| 2 | 2 | ||
| 3 | 3 | **Problem 1** | |
| 4 | 4 | ||
| 5 | 5 | Find the first 10 numbers in the Fibonacci sequence. The Fibonacci sequence starts with two numbers: | |
| 6 | 6 | ||
| 7 | - | ||
| 7 | + | ``` | |
| 8 | + | 1 1 | |
| 9 | + | ``` | |
| 8 | 10 | ||
| 9 | 11 | Each subsequent number is formed by adding the two numbers before it. 1+1=2, 1+2=3, 2+3=5, etc. This forms the following sequence: | |
| 10 | 12 | ||
| 11 | - | ||
| 13 | + | ``` | |
| 14 | + | 1 1 2 3 5 8 13 21 34 55 89 144 ... | |
| 15 | + | ``` | |
| 12 | 16 | ||
| 13 | 17 | **Problem 2** | |
| 14 | 18 | ||
| 15 | 19 | Display all powers of 2 that are less than 20000. Display the list in a properly formatted manner, with commas between the numbers. Display five numbers per line. The output should look like: | |
| 16 | 20 | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 21 | + | ``` | |
| 22 | + | 1, 2, 4, 8, 16, | |
| 23 | + | 32, 64, 128, 256, 512, | |
| 24 | + | 1024, 2048, 4096, 8192, 16384 | |
| 25 | + | ``` | |
| 20 | 26 | ||
| 21 | 27 | --- | |
| 22 | 28 | *From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 3/Programming Assignment", as it stood on 2022-08-20 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
