Problem # 13 : The number tree

Shown below is a number tree which is uniquely specified if one number in each of the 'n' rows is known.

[Number Tree]

The relation between the numbers is : x1=x2+x3 x2=x4+x5 x3=x5+x6....
Write a SUB-routine TREE(N A()) which generates such a tree when one number in each of the 'N' rows is given in the array A().

Sample Output
N=4
A(1 1)=10 'number x1
A(2 1)=5 'number x2
A(3 2)=1 'number x5
A(4 4)=10 'number x10
CALL TREE(N A()) should return

 
[Sample Output]

Previous Problem
Return to problems at The Vault
(Back to problems at The Vault )
Next Problem

LinkExchange
LinkExchange Member
1