Vés al contingut

Plantilla:Rand

De la Viquipèdia, l'enciclopèdia lliure
Icona de documentació de mòdul Documentació de la plantilla [ mostra ] [ modifica el codi ] [ mostra l'historial ] [ refresca ]

Utilització

Genera un nombre pseudoaleatori entre 0 i el valor màxim-1.

Usage:
  • {{Rand|màxim|seed|num. primer}}
  • All parameters are optional and have default values. They must be integers.
  • The default count is 100 (so by default, this template generates values between 0 and 99) and must be non-zero.
  • The default seed is 7 and can be set to any other integer value (used to generate distinct values on the same page).
  • The default prime is 67 and should be a prime number above 17 (used to generate distinct values on the same page).
Examples generating numbers between 0 and 999:
  • {{Rand|1000}} → 412
  • {{Rand|1000|7|67}} → 965 (same as above)
  • {{Rand|1000|7|61}} → 22 (this and others should all be different)
  • {{Rand|1000|6}} → 898
  • {{Rand|1000|5}} → 831
  • {{Rand|1000|4}} → 764
  • {{Rand|1000|3}} → 697
  • {{Rand|1000|2}} → 630
  • {{Rand|1000|1}} → 563
  • {{Rand|1000|0|61}} → 595
  • {{Rand|1000|0|67}} → 496
  • {{Rand|1000|0|71}} → 103
  • {{Rand|1000|0|73}} → 444
  • {{Rand|1000|0|79}} → 341
Note:
  • Varying seed linearily generates numbers that generates a linear sequence with equal steps;
  • Varying prime (provided that they are odd prime numbers) generates pseudo-random that have better random distribution.