Skip to content

Instantly share code, notes, and snippets.

@buccolo
Created December 15, 2011 22:00
Show Gist options
  • Save buccolo/1483107 to your computer and use it in GitHub Desktop.
Save buccolo/1483107 to your computer and use it in GitHub Desktop.
Euler Phi (n)
#!/usr/bin/ruby
require 'rational'
number = ARGV[0].to_i
current = 0
phi = 0
while (current < number)
if (number.gcd(current) == 1)
phi = phi + 1
end
current = current + 1
end
puts phi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment