# Modular arithmetic for a generic and efficient divisibility rule

I'm new to number theory, however, I wanted to do a course in cryptography that requires me to have understood a decent amount of number theory.

I started watching a course on Coursera. I did not understand the part where the professor explains the generic algorithm for finding if a number of any base, is divisible by another.

Here is the link to the lecture: Modular arithmetic. He starts explaining at around 12 minutes into the video.

I have copied a description of the algorithm as given in the slides:-

x = 5432 = ( ( (0 + 5)·10 + 4 )·10 + 3 )·10 + 2

Can perform mod reductions as desired.

If divisor ≤ base, reduce digits and base first

Powerful general algorithm

Easily implemented in a program

Space efficient: Largest sum < base·divisor

Time efficient: O(log(v))

Base/divisor-specific algorithms can be faster

I don't understand what is the "powerful general algorithm" that he describes, to find divisibility of any number of any arbitrary base by another number. Could some one please help me understand what the algorithm is ? how does it achieve the space and time efficiency that he claims ?

I'm sorry for the bad references. I tried finding the algorithm on the internet but I could not find any references.

• A personal advice : Do not try to learn such basic topics with videos. Rather read articles. Commented Sep 19, 2018 at 20:17
• Thanks for the advice Peter. Could you suggest a book that will help me cover these topics, please ? I'm interested only in concepts that are related to / use in cryptography. Commented Sep 19, 2018 at 20:21
• Usually I read articles online. But it should not be hard to find a suitable book. Commented Sep 19, 2018 at 20:22
• Start reading the Wikipedia articles, for an introduction, I think, they are very useful. Commented Sep 19, 2018 at 20:27
• I'm trying to understand that part from Coursera as well. Sometimes, this lecturer's logic seems completely missing. Commented Apr 5 at 2:39