0

i need a php function that can result like this. example when i call the function

echo Prime(4,3);

2 3 5 7
11 13 17 19
23 29 31 37

anyone can help please help me.

Rifano
  • 3
  • 1
  • 2
    Welcome to Stackoverflow! Be sure to take a [tour](https://stackoverflow.com/tour) and visit the [help center](https://stackoverflow.com/help). As it is, your question is off-topic because you do not provide any code written by you. We can only help if you've tried to do something. – Michail Nov 03 '18 at 06:25
  • Possible duplicate of [What is the best algorithm for checking if a number is prime?](https://stackoverflow.com/questions/1801391/what-is-the-best-algorithm-for-checking-if-a-number-is-prime) – Nick Nov 03 '18 at 06:37

1 Answers1

0
function primenumbers($n, $m){

$number = $n*$m;
    $numCounter = 0;
    $i = 0;
    while($numCounter < $number){
         $counter = 0; 
          for($j=1;$j<=$i;$j++){
                if($i % $j==0){ 
                      $counter++;
                }
          }
        if($counter==2){
            print $i." ";
            $numCounter++;
        }
        if($numCounter % $m == 0){
        print  "<br>";
        }   
        $i++;

    } 

}
echo primenumbers(3,5);
PushpikaWan
  • 2,437
  • 3
  • 14
  • 23