Quick and dirty way to find primes


2..5000 | ForEach-Object{
    $current = $_
    $f = @()
    1..$Current | ForEach-Object{
        $result = $current/$_
        If($result.GetType().Name -eq "Int32"){
            $f += $result
        }
    }
    if($f.count -le 2){
        $current
    }
}

Leave a Reply