I have to write a program where I check if an int is a prime number. If it is, I have to cut the most significant digit and check if the new number is prime, again I cut the most significant digit and check again, until my number is 1 digit long.
For example if I have 547, I check if it is prime. After I've verified that it is, I cut the 5 and check if 47 is prime, then I check if 7 is prime.
The only part of the code I need is the one to cut the number. I'm sorry if I cannot include my code, but at the moment I have no idea how to do it. Could you suggest a solution both in an arithmetic way and by using a function? (if a function that can do that exists)
By arithmetic I mean, just by using standard mathematical operations, I know for example how to cut the least significant digit:
num = num / 10;
So that 547 would become just 54 and so on.