Largest multiple of $7$ lower than some $78$-digit number? What I am trying to achieve, is related to cryptography/blockchain/bitcoin . So, the largest number here is huge, in other words: I want to find the largest multiple of 7, which is lower than this number:
$115792089237316195423570985008687907852837564279074904382605163141518161494336 $
I can just go to Wolfram Alpha, and type "multiples of 7", and I get a list of the multiples relatively fast. But, it will take some time until I keep hitting "more", to get to a number lower than this above. 
 A: One can compute this number $a$ modulo $7$. The result is $2\bmod 7$. So take $a-2$. It is the largest multiple of $7$ less than $a$.
A: Just divide the number by 7, if the mod is 0, you subtract 1 from the quotient and multiply it by 7, else, the quotient times 7 is your desired number.
Ex:
70 / 7 = 10, with mod 0. 10-1 = 9 => 9 * 7 = 63 >Biggest multiple under 70.
71 / 7 = 10, with mod 1. 10 * 7 = 70 => Biggest multiple under 71
A: Yet another way would be to calculate the iterated scalar product described in this question:
As far as I know we can generate this vector $\bf v$ to take scalar product with by taking the sequence $${\bf v}_{k+1} = (10^k) \mod 7$$
Furthermore, to calculate $10^k \mod 7$, we can do this on the fly as well by the following algorithm:


*

*Start exponent $k=0$, $a_0 = 1 = 10^0\mod (7)$

*Calculate $a = 10\cdot a$. This number will for reasons explained later be in range $\{10,11,\cdots,60\}$.

*Now find $x: a = x \mod 7$, this can for example be done fast by a lookup table.

*Increment $k: k = k+1$, 

*Set $a_k = x$

*Loop back to $2$ for as long as we still have digits.



This way to calculate will be $\mathcal O(n)$ complexity for $n$ decimal digits for each scalar product, because the first number we have will shrink down to $5\cdot \log_{10}(n)$. And we need to get down to 1 digit, this means we need to do inverse logtower function(n). An extreeemely fast decaying function. For a 1000 digit number $\approx 10^{1000}$, averaging 5 multiplied by on average 3 $\approx 5\times 3\cdot 1000 = 1.5\cdot 10^{4}$ which is $4$ decimal digit, then next one will be $2$ decimal digit and then we are done.
