mardi 25 avril 2023

How to generate extremely large numbers?

What is the best way to generate large random numbers (bigger than 10e32)? I have seen a lot of things for better generations (mt19937 instead of rand()) but they are still relatively limited in size.

#include <iostream>
#include <random>
using std::cin;
using std::cout;

int main() {
    long long userImput;
    cin >> userImput;
    std::random_device rd;
    std::mt19937_64 gen(rd());
    std::uniform_int_distribution\<long long\> dist(3, userImput);
    long long randomNum = dist(gen);
    cout << randomNum;
};
//result of large imputs is maxed at around 10e20



Aucun commentaire:

Enregistrer un commentaire