Powershell: Stress your CPU with some Prime Numbers

#get number of cores
$cpu = Get-WmiObject win32_processor | Select-Object Numberoflogicalprocessors
$cores = [convert]::ToInt32($cpu.Numberoflogicalprocessors, 10)

#define functions
function get-prime($i){
        
     for ($a=3; $a -lt $i; $a++){
        if ($i % $a -eq 0){
            return "no"
        }
        else{}
     }
}
    
#create a task for each core
foreach ($core in 1..$cores){
    start-job -ScriptBlock {
        
        for ($i=1000000; $i -le 10000000; $i++){
            $prime = get-prime($i)
            if ($prime -ne "no"){
                write-output "$i"
                }
            else {}
        }
    }

}

Wait-job *
clear
Receive-Job *
remove-job