find the given number is magic or not in java program