Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Get-Random

$
0
0

I was asked whether it is better to create an 8 digit random number using a maximum of 99999999 or 0-9 8 times and reassmbling the 8 digits.  The time is certaining shorter using 0-9 8 times but is it a better random number?

I couldn't answer the question.  Any ideas?

 

 

$a 

 

 

= (0..9) | Get-Random;$b= (0..9) | Get-Random;;$c= (0..9) | Get-Random;$d= (0..9) | Get-Random;$e= (0..9) | Get-Random;$f= (0..9) | Get-Random;$g= (0..9) | Get-Random;$h= (0..9) | Get-Random;$x= [string]$a+ [string]$b+ [string]$c+ [string]$d+ [string]$e+ [string]$f+ [string]$g+ [string]$h;$y= [string]$x ;$y

versus - which would need additional logic to assure 8 digit results

 

 

$a=Get-Random-Maximum 99999999 ;$a


Viewing all articles
Browse latest Browse all 6937

Latest Images

Trending Articles



Latest Images