Print Prime Number From 1 To 100 In Php - Php

How to print prime number from 1 to 100 using php?

Snippet Code


  
Rate this page :
  [ 0 votes]

The sample php code used to display prime numbers from 1 to 100. The php code to print prime numbers is given below.

<?php $num = 1 ; while ($num < 100 ) { $count=0; for ( $i=1;$i<=$num;$i++) { if (($num%$i)==0) { $count++; } } if ($count<3) { echo $num." , "; } $num=$num+1; } ?>

Tags


Ask Questions

Ask Question