PHP Classes
Icontem

File: example2.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of zandor  >  Primes Factory  >  example2.php  
File: example2.php
Role: Example script
Content type: text/plain
Description: example of Erathostenes' sieve
Class: Primes Factory
Perform calculations with prime numbers
 

Contents

Class file image Download
<?php

require_once('primesfactory.php');

$n $_GET['number'];

if ( 
strlen($n) == )
{
    echo 
"No number was input.<br/>";
    echo 
"Come <a href=\"javascript:history.back(1);\">back</a> to the form and retry." ;
    return ;
}

$pf = new primesfactory ;

$pf->insert_number$n );
$pf->go();

if ( !
$pf->isok() ) $pf->display_error();
else
{
      echo 
"<b>The sieve of Eratosthenes</b><br/><br/><font color=#EEEE00><b>Primes</b></font> before <b>$n</b> are:<br/><br/>" ;
      
      
$columns 14 ;
      
      echo 
"<table style=\"padding:2px;border:1px solid #dedede;\">\n" ;
      echo 
"\t<tr>\n" ;
      
      for ( 
$i $i <= $n $i++ )
      {
            if ( 
$pf->isprime$i ) ) echo "\t\t<td align=\"center\" style=\"border:1px solid black;\"><font color=#EEEE00 size=\"5\"><b>$i</b></font></td>\n";
            else echo 
"\t\t<td align=\"center\"><font color=#0000EE size=\"5\">$i </font></td>\n" ;
            
            echo 
"<td width=\"5\"><td>";
            
            if ( 
$i $columns == ) echo "</tr>\n\t<tr>\n" ;
      }

      echo 
"</table>\n" ;
      
}

?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products