1** Copyright (c) 1989, NVIDIA CORPORATION.  All rights reserved.
2**
3** Licensed under the Apache License, Version 2.0 (the "License");
4** you may not use this file except in compliance with the License.
5** You may obtain a copy of the License at
6**
7**     http://www.apache.org/licenses/LICENSE-2.0
8**
9** Unless required by applicable law or agreed to in writing, software
10** distributed under the License is distributed on an "AS IS" BASIS,
11** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12** See the License for the specific language governing permissions and
13** limitations under the License.
14
15* Recurrence recognition.
16
17	program p
18	parameter (N=23)
19	common iresult(60)
20	dimension iexpect(N)
21	data iexpect /
22     +    1, 1, 1, 1,		! /* t0:  1 - 4  */
23     +    2, 2, 2, 2,		! /* t1:  5 - 8  */
24     +    3, 4, 3, 4, 3, 4,	! /* t2:  9 - 14 */
25     +    1, 1, 1, 4,		! /* t3: 15 - 18 */
26     +    1, 2, 3, 5, 8		! /* t4: 19 - 23 */
27     +  /
28
29	iresult(1) = 1
30	call t0(4)
31
32	iresult(8) = 2
33	call t1(5, 8)
34
35	iresult(9) = 3
36	iresult(10) = 4
37	call t2(9, 11)
38
39	iresult(15) = 1
40	iresult(16) = 2
41	call t3(15, 16)
42
43	iresult(19) = 1
44	iresult(20) = 2
45	call t4(19, 21)
46
47	call check(iresult, iexpect, N)
48	end
49
50	subroutine t0(n)
51	common iresult(60)
52	do i=1, n-1
53	    iresult(i+1) = iresult(i)
54	enddo
55	end
56
57	subroutine t1(l,u)
58	integer u
59	common iresult(60)
60	do i=u, l+1, -1
61	    iresult(i-1) = iresult(i)
62	enddo
63	end
64
65	subroutine t2(l,u)
66	integer u
67	common iresult(60)
68        do i=l, u, 2
69	    iresult(i+2) = iresult(i)
70	    iresult(i+3) = iresult(i+1)
71	enddo
72	end
73
74	subroutine t3(l,u)
75	integer u
76	common iresult(60)
77        do i=l, u
78c	/* i+1, i is the only valid recurrence */
79	    iresult(i+2) = iresult(i+1) + iresult(i)
80	    iresult(i+1) = iresult(i)
81	enddo
82	end
83
84	subroutine t4(l,u)
85        integer u
86	common iresult(60)
87        do i=l, u
88	    iresult(i+2) = iresult(i+1) + iresult(i)
89	enddo
90	end
91