Skip to content

Instantly share code, notes, and snippets.

@whatAboutJohn
Last active August 29, 2015 14:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatAboutJohn/9e61f494090998fc2591 to your computer and use it in GitHub Desktop.
Save whatAboutJohn/9e61f494090998fc2591 to your computer and use it in GitHub Desktop.
include Math
require "bigdecimal/math"
include BigMath
# Sum all odd PI digits from 1 to 31415
PI(31415).to_digits.tr('.', '').split('').select.each_with_index {|s, i| i.even?}.tap {|x| p x.map(&:to_i).inject(0, &:+)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment