=begin The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97. How many circular primes are there below one million? =end load 'library.rb' primesar = primesUpTo(1000000) primes = {} primesar.each do |p| primes[p.to_s] = true end print("Processing...\n") circular = [] primesar.each do |p| primestr = p.to_s circ = true length = primestr.length 1.upto length do |n| primestr = primestr[1,length]+primestr[0,1] if primes[primestr].nil? circ = false break end end if circ print("Circular: "+primestr+"\n") circular.push p end end print circular.length