how to check a number is a magic number or not in java