9 billion names of God the integer: Difference between revisions
Content added Content deleted
(Created page with "{{task}} This task is a variation of the short story by Arthur C. Clark. Solvers should be aware of the consequences of completing this task, see: [http://en.wikipedia.org/wik...") |
m (Tidy up task description) |
||
Line 1: | Line 1: | ||
{{task}} |
{{task}} |
||
This task is a variation of the short story by Arthur C. Clark. Solvers should be aware of the consequences of completing this task, see: |
This task is a variation of the short story by Arthur C. Clark. Solvers should be aware of the consequences of completing this task, see: |
||
* [[wp:The Nine Billion Names of God#Plot_summary|Plot summary of The Nine Billion Names of God]]. |
|||
In detail, to specify what is meant by a “name” |
|||
:The integer 1 has 1 name 1. |
|||
:The integer |
:The integer 1 has 1 name “1”. |
||
:The integer |
:The integer 2 has 2 names “1+1”, and 2. |
||
:The integer |
:The integer 3 has 3 names “1+1+1”, “2+1”, and “3”. |
||
:The integer |
:The integer 4 has 5 names “1+1+1+1”, “2+1+1”, “2+2”, “3+1”, “4”. |
||
:The integer 5 has 7 names “1+1+1+1+1”, “2+1+1+1”, “2+2+1”, “3+1+1”, “3+2”, “4+1”, “5”. |
|||
;Task |
|||
The task is to display the first 25 rows of a number triangle which begins: |
The task is to display the first 25 rows of a number triangle which begins: |
||
<pre> |
<pre> |
||
Line 18: | Line 20: | ||
</pre> |
</pre> |
||
Where row n corresponds to integer n, and each column C in row |
Where row <math>n</math> corresponds to integer <math>n</math>, and each column <math>C</math> in row <math>m</math> from left to right corresponds to the number of names begining with <math>C</math>. |
||
A function G(n) should return the sum of the names for that row. Demonstrate this function by displaying: G(23), G(123), G(1234), and G(12345). |
A function <math>G(n)</math> should return the sum of the names for that row. Demonstrate this function by displaying: <math>G(23)</math>, <math>G(123)</math>, <math>G(1234)</math>, and <math>G(12345)</math>. |
||
Extra credit |
;Extra credit |
||
If your environment is able, plot G(n) against n for n=1 |
If your environment is able, plot <math>G(n)</math> against <math>n</math> for <math>n=1\ldots 999</math>. |
Revision as of 14:08, 27 April 2013
![Task](http://static.miraheze.org/rosettacodewiki/thumb/b/ba/Rcode-button-task-crushed.png/64px-Rcode-button-task-crushed.png)
You are encouraged to solve this task according to the task description, using any language you may know.
This task is a variation of the short story by Arthur C. Clark. Solvers should be aware of the consequences of completing this task, see:
In detail, to specify what is meant by a “name”
- The integer 1 has 1 name “1”.
- The integer 2 has 2 names “1+1”, and 2.
- The integer 3 has 3 names “1+1+1”, “2+1”, and “3”.
- The integer 4 has 5 names “1+1+1+1”, “2+1+1”, “2+2”, “3+1”, “4”.
- The integer 5 has 7 names “1+1+1+1+1”, “2+1+1+1”, “2+2+1”, “3+1+1”, “3+2”, “4+1”, “5”.
- Task
The task is to display the first 25 rows of a number triangle which begins:
1 1 1 1 1 1 1 2 1 1 1 2 2 1 1 1 3 3 2 1 1
Where row corresponds to integer , and each column in row from left to right corresponds to the number of names begining with .
A function should return the sum of the names for that row. Demonstrate this function by displaying: , , , and .
- Extra credit
If your environment is able, plot against for .