Skip to content

Instantly share code, notes, and snippets.

@zuchmanski
Created June 14, 2010 17:47
Show Gist options
  • Save zuchmanski/438007 to your computer and use it in GitHub Desktop.
Save zuchmanski/438007 to your computer and use it in GitHub Desktop.
require 'mechanize'
require "prime"
agent = Mechanize.new
primes = Prime.new
pr = primes.next
results = []
while (pr <= 1000) do
pr = primes.next
agent.get("http://wolframalpha.com")
form = agent.page.forms.first
form.i = "1/#{pr}"
form.submit
v = agent.page.search("#i_0400_1").first.attributes["alt"].value
if v =~ /period/
results << [pr, v.scan(/period \d+/).first.gsub("period ", "").to_i]
end
end
puts a.max { |a, b| a[1] <=> b[1] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment