login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A372727 Triangle read by rows: T(n, k) = n if k = 0, otherwise n - k*floor(n/k). The binary modulo operation. 1

%I #22 Jul 22 2024 00:08:56

%S 0,1,0,2,0,0,3,0,1,0,4,0,0,1,0,5,0,1,2,1,0,6,0,0,0,2,1,0,7,0,1,1,3,2,

%T 1,0,8,0,0,2,0,3,2,1,0,9,0,1,0,1,4,3,2,1,0,10,0,0,1,2,0,4,3,2,1,0,11,

%U 0,1,2,3,1,5,4,3,2,1,0,12,0,0,0,0,2,0,5,4,3,2,1,0

%N Triangle read by rows: T(n, k) = n if k = 0, otherwise n - k*floor(n/k). The binary modulo operation.

%C The binary operation 'mod' as defined here is discussed in 'Concrete Mathematics' by Graham et. al. on p. 82 and the connection with the congruence relation '(mod)' on p. 123. See also Bach & Shallit, p. 21, and Apostol, p. 14.

%C This definition is implemented in Sage, but not in Python. For example, Sage answers 0.mod(0) = 0, whereas in Python 0 % 0 leads to a 'ZeroDivisionError'. What is often misunderstood is that the operation 'mod' gives answers to divisibility, not to division. Apostol shows that n|0 (every integer divides zero), but 0|n implies n = 0 (zero divides only zero), and thus confirms the result given by Sage.

%D Tom Apostol, Introduction to analytic number theory, 1976, Springer, page 14.

%D Eric Bach and Jeffrey Shallit, Algorithmic Number Theory, 1997, p. 21.

%D Ronald L. Graham, Donald E. Knuth and Oren Patashnik, Concrete Mathematics, 2nd ed., Addison-Wesley, 1994, 34th printing 2022, p. 81f.

%e Triangle begins:

%e [ 0] 0;

%e [ 1] 1, 0;

%e [ 2] 2, 0, 0;

%e [ 3] 3, 0, 1, 0;

%e [ 4] 4, 0, 0, 1, 0;

%e [ 5] 5, 0, 1, 2, 1, 0;

%e [ 6] 6, 0, 0, 0, 2, 1, 0;

%e [ 7] 7, 0, 1, 1, 3, 2, 1, 0;

%e [ 8] 8, 0, 0, 2, 0, 3, 2, 1, 0;

%e [ 9] 9, 0, 1, 0, 1, 4, 3, 2, 1, 0;

%e [10] 10, 0, 0, 1, 2, 0, 4, 3, 2, 1, 0;

%e [11] 11, 0, 1, 2, 3, 1, 5, 4, 3, 2, 1, 0;

%e .

%e The triangle shows the modulo operation in the range 0 <= k <= n. Test your

%e computer implementation in the range R X R where R = [-6, ..., 0, ..., 6].

%e According to Graham et al. it should look like this:

%e 0, -1, -2, 0, 0, 0, -6, 0, 0, 0, 2, 4, 0

%e -5, 0, -1, -2, -1, 0, -5, 0, 1, 1, 3, 0, 1

%e -4, -4, 0, -1, 0, 0, -4, 0, 0, 2, 0, 1, 2

%e -3, -3, -3, 0, -1, 0, -3, 0, 1, 0, 1, 2, 3

%e -2, -2, -2, -2, 0, 0, -2, 0, 0, 1, 2, 3, 4

%e -1, -1, -1, -1, -1, 0, -1, 0, 1, 2, 3, 4, 5

%e 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

%e -5, -4, -3, -2, -1, 0, 1, 0, 1, 1, 1, 1, 1

%e -4, -3, -2, -1, 0, 0, 2, 0, 0, 2, 2, 2, 2

%e -3, -2, -1, 0, -1, 0, 3, 0, 1, 0, 3, 3, 3

%e -2, -1, 0, -2, 0, 0, 4, 0, 0, 1, 0, 4, 4

%e -1, 0, -3, -1, -1, 0, 5, 0, 1, 2, 1, 0, 5

%e 0, -4, -2, 0, 0, 0, 6, 0, 0, 0, 2, 1, 0

%p MOD := (n, k) -> ifelse(k = 0, n, n - k * iquo(n, k)):

%p seq( seq(MOD(n, k), k = 0..n), n = 0..12);

%o (SageMath)

%o def T(n, k): return n.mod(k)

%o for n in srange(12): print([T(n, k) for k in range(n + 1)])

%o (Python)

%o def T(n, k): return n if k == 0 else n - k * (n // k)

%o for n in range(12): print([T(n, k) for k in range(n + 1)])

%o (Python)

%o def A372727_T(n, k): return n % k if k else n # _Chai Wah Wu_, May 14 2024

%Y Cf. A111490 (row sums).

%Y Cf. A048158.

%K nonn,tabl

%O 0,4

%A _Peter Luschny_, May 13 2024

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 11 10:58 EDT 2024. Contains 375068 sequences. (Running on oeis4.)