dimanche 5 mars 2023

How to make a random function without using any library?

I know that the way to produce random numbers from 0 to 1 (0.0 ≤ n < 0.1) can be done using a code like this in Python:

import random
print(random.random())

But I'm curious about how this function can be made and how it works. Is anyone who can explain how to make a random function from the scratch without using any library?

The result I want:

def getRandom():
  # return float between 0 and 1 (0 ≤ n < 1)

I have found several website sources, but I don't get a good understanding of it.




Aucun commentaire:

Enregistrer un commentaire