Ask Your Question
0

base-n expansion of integers

asked 2024-03-07 15:15:30 +0200

dantetante gravatar image

updated 2024-03-09 03:39:07 +0200

Max Alekseyev gravatar image

If I use Integer('z',36) I get 35 as expected, but Integer('z',37) throws an error, from which I deduce that possible bases for n-adic expansion are {2,3,...,36} and 1, 2, 3, ..., 8, 9, a=10(dez), b=11(dez), ..., z=35(dez) is the maximal possible digit set.

What can I do if I wanted to get the expansion for a larger base? Do I have to reinvent the wheel?

Note that I do want to not only use primes as basis.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2024-03-07 17:59:25 +0200

Max Alekseyev gravatar image

A possible solution is to use numerical representation for digits:

sage: ZZ(100).digits(37)
[26, 2]
sage: ZZ([26, 2], 37)
100
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-03-07 15:15:30 +0200

Seen: 108 times

Last updated: Mar 07