Calculations Needing Big Integers....
#1
Does QB64pe have the capability for Big Integers?

Below I pasted python (P3) code that calculates the first 5,000 Fibonacci numbers as shown.  Takes about 1 second.  It automatically uses Big Integers with no adjustment.

Can we do something similar with QB64pe?  I would guess there is at least one or more ways to run a similar calculation.  Thanks in advance !!!

Python Code for Fibonacci Sequence
def fibIter(n):
    if n < 2:
        return n
    fibPrev = 1
    fib = 1
    for _ in range(2, n):
        fibPrev, fib = fib, fib + fibPrev
    return fib

for i in range(0, 5000):
    print(fibIter(i))

This is the 5000th Fibonacci Number (it has 1,045 digits)  I skipped 1 to 4,999.
2397334346100631452333336800023778743396400988090212332865227234032387117767626167465060795065595580850691237390963845987165478074085124644348902530685083246709423858342692329718110162972268152200857232686119638781547238020078362945470777668711057069618425746387920931255084621360135655698456629322111614827324455767748623844363426260372374195153577101298837831208580530677289982029527164306876024342838547454228388796380077029917639469963653048076473269452943584037848773158456736367057460079075603072996653089318046279296240100777360367200040226807430924334616931577257195085793060133817911514540227011756335999604550121968663793604830945238116686325506344893928776515696088851468818023735825546502317562957459506612704850760351077006532507519813600498603205937022956740021970327599548184626715032015801445754074519753924901317605013561516613650173445818028242577356369143977719495739428130191089993769093308407443558168431535751910046557480949313497996285124526992631353143367314930548703966553707195171094152730704138121243470432644848607501
Reply


Messages In This Thread
Calculations Needing Big Integers.... - by Space_Ghost - 07-09-2023, 03:58 AM



Users browsing this thread: 10 Guest(s)