--- /dev/null
+require 'ruby-prof'
+load 'primes.rb'
+
+class Array
+ def to_i
+ self.map {|d| d.to_s}.join.to_i
+ end
+
+ def to_r
+ Rational(self[0].to_i, self[1].to_i)
+ end
+
+ def all_rotations
+ (0...self.length).map {|r| self.rotate(r)}
+ end
+end
+
+class Integer
+ @@primes = Primes.instance
+
+ def prime?
+ @@primes.include? self
+ end
+
+ def pl
+ @@primes.primes.length
+ end
+
+ def circular_prime?
+ self.to_digits.all_rotations.map {|n| n.to_i}.all? {|n| n.prime?} if self.prime?
+ end
+
+ def to_digits
+ self.to_s.split('').map {|d| d.to_i}
+ end
+end
+
+
+(10**6).prime?
+
+RubyProf.start
+
+pl0 = 0.pl
+beginning_time = Time.now
+cps = (2..10**6).select {|n| n.circular_prime?}
+end_time = Time.now
+pl1 = 0.pl
+puts "Time elapsed #{(end_time - beginning_time)} seconds, going from #{pl0} to #{pl1} primes cached"
+puts cps.length
+
+result = RubyProf.stop
+
+printer = RubyProf::MultiPrinter.new(result)
+printer.print(:path => ".", :profile => "profile")
+
+