Last active
November 24, 2017 13:16
-
-
Save lbvf50mobile/b508165ea7b226ebb530f7404e53b1f5 to your computer and use it in GitHub Desktop.
prime simple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://www.codewars.com/kata/stone-bridge-primes/train/ruby | |
| require "prime" | |
| def solve(x,y) | |
| a = [] | |
| for m in 0..10 | |
| for n in 0..10 | |
| a << calc(m,n) | |
| end | |
| end | |
| ans = a.select{|e| Prime.prime?(e)}.sort.select{|e| e >= x and e < y }.size | |
| end | |
| def calc(m,n) | |
| p_ = 2**m * 3**n + 1 | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment