Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

60%
+1 −0
Challenges Ratio limits of fibonacci-like series

Python 3, 26 bytes lambda n:(n+(n*n+4)**.5)/2 We can actually just compute this directly, although I could have taken an alternate path considering the fact that, given $R_n$ as the ratio betwe...

posted 12d ago by CrSb0001‭  ·  edited 3d ago by CrSb0001‭

Answer
#2: Post edited by user avatar CrSb0001‭ · 2025-04-16T18:47:37Z (3 days ago)
  • # Python 3, 26 bytes
  • ```python
  • lambda n:(n+(n*n+4)**.5)/2
  • ```
  • We can actually just compute this directly, although I could have taken an alternate path considering the fact that, given $R_n$ as the ratio between any two terms in the $n$-fibonacci sequence defined above (where $n\in\mathbb Z$), then$$R_{-n}=R_n-n$$or equivalently,$$R_n=R_{-n}+n$$although it seems like it would have cost me an additional 21 bytes:
  • ```python
  • f=lambda n:(n+(n*n+4)**.5)/2if n>=0else f(-n)+n
  • ```
  • ---
  • Explanation of the above statement:
  • >We can write $G(x)=F_n(x)$ for arbitrary $n\in\mathbb Z$. Now, we can write $G(x)$ in recurrence relation form as$$\lambda^2-n\lambda-1=0$$The solution to this equation (let'_s call this $\lambda_+$),$$\lambda_+=\dfrac{n+\sqrt{n^2+4}}2$$gives the ratio of one term to the next as $x\to\infty$, because $G$ does not depend on parameter $n$.
  • >
  • >Now, if we let $G(x)=F_{-n}(x)$, the recurrence relation now becomes$$\lambda^2+n\lambda-1=0$$and now our ratio between terms is$$\lambda_-=\dfrac{-n+\sqrt{n^2+4}}2$$Finally, we get $\lambda_+-\lambda_-=n$, or equivalently$$\lambda_+=\lambda_-+n$$$$\lambda_-=\lambda_+-n$$
  • # Python 3, 26 bytes
  • ```python
  • lambda n:(n+(n*n+4)**.5)/2
  • ```
  • We can actually just compute this directly, although I could have taken an alternate path considering the fact that, given $R_n$ as the ratio between any two terms in the $n$-fibonacci sequence defined above (where $n\in\mathbb Z$), then$$R_{-n}=R_n-n$$or equivalently,$$R_n=R_{-n}+n$$although it seems like it would have cost me an additional <s>21</s> 19 bytes:
  • ```python
  • f=lambda n:n+f(-n)if n<0else(n+(n*n+4)**.5)/2
  • ```
  • <sup>-2 bytes by rearranging the terms<sup>
  • ---
  • Explanation of the above statement:
  • >We can write $G(x)=F_n(x)$ for arbitrary $n\in\mathbb Z$. Now, we can write $G(x)$ in recurrence relation form as$$\lambda^2-n\lambda-1=0$$The solution to this equation (let'_s call this $\lambda_+$),$$\lambda_+=\dfrac{n+\sqrt{n^2+4}}2$$gives the ratio of one term to the next as $x\to\infty$, because $G$ does not depend on parameter $n$.
  • >
  • >Now, if we let $G(x)=F_{-n}(x)$, the recurrence relation now becomes$$\lambda^2+n\lambda-1=0$$and now our ratio between terms is$$\lambda_-=\dfrac{-n+\sqrt{n^2+4}}2$$Finally, we get $\lambda_+-\lambda_-=n$, or equivalently$$\lambda_+=\lambda_-+n$$$$\lambda_-=\lambda_+-n$$
#1: Initial revision by user avatar CrSb0001‭ · 2025-04-07T19:40:04Z (12 days ago)
# Python 3, 26 bytes

```python
lambda n:(n+(n*n+4)**.5)/2
```

We can actually just compute this directly, although I could have taken an alternate path considering the fact that, given $R_n$ as the ratio between any two terms in the $n$-fibonacci sequence defined above (where $n\in\mathbb Z$), then$$R_{-n}=R_n-n$$or equivalently,$$R_n=R_{-n}+n$$although it seems like it would have cost me an additional 21 bytes:
```python
f=lambda n:(n+(n*n+4)**.5)/2if n>=0else f(-n)+n
```

---

Explanation of the above statement:

>We can write $G(x)=F_n(x)$ for arbitrary $n\in\mathbb Z$. Now, we can write $G(x)$ in recurrence relation form as$$\lambda^2-n\lambda-1=0$$The solution to this equation (let'_s call this $\lambda_+$),$$\lambda_+=\dfrac{n+\sqrt{n^2+4}}2$$gives the ratio of one term to the next as $x\to\infty$, because $G$ does not depend on parameter $n$.
>
>Now, if we let $G(x)=F_{-n}(x)$, the recurrence relation now becomes$$\lambda^2+n\lambda-1=0$$and now our ratio between terms is$$\lambda_-=\dfrac{-n+\sqrt{n^2+4}}2$$Finally, we get $\lambda_+-\lambda_-=n$, or equivalently$$\lambda_+=\lambda_-+n$$$$\lambda_-=\lambda_+-n$$