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?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.Sign up to join this community
It depends whether you want a three-digit number, in which case try using
Mod, as in:
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
Mod[a,1000] == 0
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][], Last[#] == 0 &], -3]