Last active
October 24, 2019 17:32
-
-
Save OverlordEx3/8d1004eeeccc9a4059378e98e7ebc14e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "dart:core"; | |
Stream<Map<int, int>> getRandomNumbers(int seed, int modulus, int increment, int multiplier, int max) async* { | |
int prevxn = seed; | |
int result = 0; | |
for(int i = 1; i <= max; i++) | |
{ | |
result = (multiplier*prevxn + increment) % modulus; | |
yield {i : result}; | |
prevxn = result; | |
} | |
} | |
void main() { | |
int seed = 7; | |
int modulus = 16; | |
int increment = 3; | |
int multiplier = 5; | |
int maximum = 32; | |
print("Calculando números pseudo aleatorios utilizando Congruencia Lineal:"); | |
print("Semilla (x0): $seed"); | |
print("Módulo: $modulus"); | |
print("Multiplicador: $multiplier"); | |
print("Cantidad de iteraciones: $maximum"); | |
/* Print */ | |
getRandomNumbers(seed, modulus, increment, multiplier, maximum). | |
listen((values) { | |
print("x${values.keys.first} = ${values.values.first}"); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment