Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- is_integral =: = <.
- repunit =: 3 : 0 "0
- 10 repunit y
- :
- NB. Gives the y-th repunit in the x base, with the result expressed
- NB. in base 10. E.g., 3 repunit 4 gives 40, because 40 in base 3 is 1111.
- ((x ^ y) - 1) % x - 1
- )
- which_repunit =: 3 : 0 "0
- 10 which_repunit y
- :
- NB. An integer solution to this equation means it's a repunit,
- NB. and returns which one it is for that base. E.g., which_repunit 111
- NB. gives the integer 3, so 111 is the third repunit in base 10.
- NB. By contrast, 112 gives 3.00389, which means it is not a repunit.
- NB.
- NB. repunit which_repunit y will always give back y, regardless of whether
- NB. y is a repunit in the given base.
- x ^. (y * (x - 1)) + 1
- )
- is_repunit =: 3 : 0 "0
- 10 is_repunit y
- :
- is_integral x which_repunit y
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement