# Determining if a number is divisible by 1000 [closed]

I have a number such as:

a = 875952;


And I want to find if it is divisible by 1000.

Is there a concise way of doing that?

Divisible[a, 1000]


False

It depends whether you want a three-digit number, in which case try using Mod, as in:

Mod[a, 1000]


If you want a List of the digits, then the other solutions above work fine.

If your goal is instead to see whether a is (evenly) divisible by 1000, then:

Mod[a,1000] == 0


yields a True or False.

Although I don't think this is quite what the OP requests, in response to @TheGreatDuck, here is (inefficient) code that gets the final three digits from any real number:

a = 3454.983745;
Take[
NestWhile[
If[Last[#] == 0, Drop[#, -1]] &, RealDigits[a][[1]],
Last[#] == 0 &], -3]

• Actually I want to see whether a is divisable by 1000, my ways is to judge the last number of a. But it seems complex. Do you have other ways? thanks. – user61054 Dec 31 '18 at 17:49
• A recommendation: Always ask your actual question, rather than an intermediate question. You're more likely to get better answers. – David G. Stork Dec 31 '18 at 17:52
• @DavidG.Stork but what if by last 3 digits we mean last 3 digits of even decimal fractions such as 13.535 returning 535 or the list {5,3,5} or any other equivalent representation? Right now your formula gives the last three whole number place values along with the decimal fraction. (And yes, I can see the askers usage/intention was something very different but it would be interesting to see a more precise answer to the original question.) – user64742 Dec 31 '18 at 20:16
• @TheGreatDuck: The OP is rather confused about what is desired: "Actually I want to see whether $a$ is divisable by 1000." I tried to answer his actual question. If the OP wants something different, I'm happy to address that. – David G. Stork Dec 31 '18 at 20:18
• @TheGreatDuck look up what an x y question is. In this case the best approach would be to edit the original question as it is not the question that the OP wants to be answered. – Fogmeister Jan 1 '19 at 10:24