Login   Register  
PHP Classes
elePHPant
Icontem

File: example1.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of zandor  >  Primes Factory  >  example1.php  >  Download  
File: example1.php
Role: Example script
Content type: text/plain
Description: example of prime factorization
Class: Primes Factory
Perform calculations with prime numbers
Author: By
Last change: none
Date: 8 years ago
Size: 777 bytes
 

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 ;
}

$entries explode"," $n );
sort($entries);
$entries_count count$entries ); 

$pf = new primesfactory ;
$pf->set_style) ;

for( 
$i $i $entries_count $i++ )
{
      
$pf->insert_number$entries[$i] );
      
$pf->go();

      if ( !
$pf->isok() ) $pf->display_error();
      else
      {
        
$d $pf->display();
        echo 
"The prime factorization of <b>$entries[$i]</b> = $d<br/>" ;
      }
}

echo 
"<br/>Come <a href=\"javascript:history.back(1);\">back</a> to the form." ;

?>