Created
December 31, 2013 05:55
-
-
Save t-murano/8193170 to your computer and use it in GitHub Desktop.
Rubyによる素因数分解と、分解された数から元の数字を生成する方法
This file contains 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
require 'prime' | |
factors = 242.prime_division | |
# もしくは factors = Prime.prime_division(242) | |
p factors #=> [[2, 1], [11, 2]] | |
composite_num = Prime.int_from_prime_division([[2, 1], [3, 1], [11, 2]]) | |
p composite_num #=> 726 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment