Last active
November 24, 2017 12:35
-
-
Save lbvf50mobile/08e9a80309550ceb174ff221f51d06d3 to your computer and use it in GitHub Desktop.
prime
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 | |
| def solve(x,y) | |
| a = [] | |
| for itr in 0..2 | |
| p "iteration #{itr}" | |
| i_fora = 2 | |
| for i in itr..itr+i_fora | |
| a << calc(i,itr) | |
| end | |
| end | |
| a | |
| end | |
| def calc(i,j) | |
| ans = 2**i * 3**j + 1 | |
| p "#{ans} = 2^#{i} * 3^#{j} + 1" | |
| ans | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment