# Can we use a recursive function to express an ordinal sequence in Python?

Asked 2 weeks ago, Updated 2 weeks ago, 0 views

Can we use a recursive function to express an ordinal sequence in Python? It's like representing a Fibonacci sequence as a recursive function.

python recursive sequence

2022-09-20 15:50

The recursive function is the same concept as the ignition equation that describes only the relationship between the nth term and the n-1 term.

The ignition equation of the ordinal sequence is

``````A(n) = A(n-1)  + d
``````

It's this.

You can use this as a recursive function.

``````def A(n):
return A(n-1) + d
``````

But there's something missing from the definition of an ordinal sequence. The initial term `A(0) = A_0`. The recursive function requires the same thing.

``````def A(n):
if n == 0:
return A_0
return A(n-1) + d
``````

This is a general expression, and the values of A_0, d must be given explicitly to define which ordinal sequence it is. `A(n) = 3n + 2` If A_0 is 2, d is 3, and the definition of the recursive function is

``````def A(n):
if n == 0:
return 2
return A(n-1) + 3
``````

I'll be like this.

Because using the general expression of an ordinal sequence is much more computationally beneficial, no one would define it as a recursive function, but it's conceptually like this.

The Fibonacci recursive function is also easily understood when compared to the Fibonacci igniter.

2022-09-20 15:50

## If you have any answers or tips

Popular Tags
python x 4519
android x 1589
java x 1455
javascript x 1363
c x 881
php x 682
html x 629
swift x 586
ios x 538
mysql x 397