123456789101112131415161718192021 |
- #!/usr/bin/ruby
- # Author: Daniel "Trizen" Șuteu
- # Date: 22 September 2016
- # License: GPLv3
- # Website: https://github.com/trizen
- # https://projecteuler.net/problem=203
- # Runtime: 0.142s
- func pascal(rows) {
- var table = Hash()
- for n in (^rows) {
- table{(0..n -> map {|k| binomial(n, k) })...} = ()
- }
- table.keys.map {|n| Num(n) }.grep { .is_square_free }.sum
- }
- say pascal(51)
|