#!/usr/bin/perl -w

# $Id: factor.pl,v 1.3 2000/12/04 03:37:03 alderman Exp $

# This spins the cpu: factor a bunch of random numbers.

TARGET: foreach $e (1..750){
    my($target) = int(rand()*200000000);
    print "Factoring $target: ";
    my($sqrt) = int(sqrt($target))+1;
  FACTOR: while($target > 1) {
      for(2..$sqrt) {
#	  print "trying $_ against $target\n";
	  if($target % $_ == 0) {
	      $target = $target / $_;
	      print "$_ \n";
	      next FACTOR;
	  }
      }
      print "$target\n";
      next TARGET;
  }
    print "\n";
}
