How to quickly find the value of each item in the following sequence.

$$$a_n=\lfloor (1+\sqrt{3})^n \rfloor$$$

Calculated in the sense of taking a mode.

Please read the new rule regarding the restriction on the use of AI tools. It applies starting from round 972.
×

# | User | Rating |
---|---|---|

1 | tourist | 4009 |

2 | jiangly | 3773 |

3 | Radewoosh | 3646 |

4 | ecnerwala | 3624 |

5 | jqdai0815 | 3620 |

5 | Benq | 3620 |

7 | orzdevinwang | 3612 |

8 | Geothermal | 3569 |

8 | cnnfls_csy | 3569 |

10 | gyh20 | 3447 |

# | User | Contrib. |
---|---|---|

1 | cry | 161 |

2 | Um_nik | 160 |

2 | maomao90 | 160 |

4 | awoo | 159 |

5 | atcoder_official | 157 |

6 | -is-this-fft- | 156 |

7 | nor | 155 |

7 | adamant | 155 |

9 | maroonrk | 152 |

10 | Dominater069 | 148 |

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Sep/15/2024 16:29:43 (h2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

Auto comment: topic has been updated by Limie (previous revision, new revision, compare).Do you want to calculate all the values from 1 to n? or just for specific large n values?

It looks like you got this from the formula a_n = 2*(a_(n-1)+a_(n-2)).

If you want all values from 1 to n that'l take at least O(n) anyway so then use the recurrence

I only want to calculate one values.

then given the fact we know its equal to this recurence, we can use matrix exponentiation to calculate values in O(logn)

here's a post that explains about this a bit more.

but $$$\lfloor (1+\sqrt{3})^n \rfloor$$$ is not equal to the formula a_n = 2*(a_(n-1)+a_(n-2)).

True, i miscalculated, but here you can find the coefficients of a recurrence with the 4 previous elements. https://oeis.org/A080041

why a(n) = A080040(n) — (1+(-1)^n)/2？

No idea, but there are coefficiebts writenn for the recurrnece. Which is a_n = 2a_(n-1)+3a_(n-2)-2(a_(n-3)+a_(n-4))

But it's fast enough, since it's exponiental, it will only be calculted in log(n). Or is the problem of float relative error, if yes can you provide the equation that have this number as solution?

Sorry,I need to calculated in the sense of taking a mode.

Auto comment: topic has been updated by Limie (previous revision, new revision, compare).