Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

After running your code :

sage: nb.parent()
Integer Ring
sage: t.parent()
Ring of integers modulo 40

Here's the rub ! Therefore :

sage: (t+nb*40).parent()
Ring of integers modulo 40

And, indeed :

sage: 566%40
6

But :

sage: (566%40).parent()
Integer Ring

and from mod? :

Docstring:     
   Return the equivalence class of n modulo m as an element of
   \ZZ/m\ZZ.

which explains your result...

HTH,

After running your code :

sage: nb.parent()
Integer Ring
sage: t.parent()
Ring of integers modulo 40

Here's the rub ! Therefore :

sage: (t+nb*40).parent()
Ring of integers modulo 40

And, indeed :

sage: 566%40
6

But :

sage: (566%40).parent()
Integer Ring

and from mod? :

Docstring:     
   Return the equivalence class of n modulo m as an element of
   \ZZ/m\ZZ.

which explains your result...

What you wanted is probably :

sage: Integer(len(exp)).quo_rem(40)
(14, 6)

because :

sage: list(map(parent, Integer(len(exp)).quo_rem(40)))
[Integer Ring, Integer Ring]

HTH,