Question: Given an integer, perhaps a long integer, calculate its score as described below. If the integer input happens to be prime then the largest digit

 Given an integer, perhaps a long integer, calculate its score as

Given an integer, perhaps a long integer, calculate its score as described below. If the integer input happens to be prime then the largest digit in the number will be added to the score otherwise the smallest digit will be subtracted from the score to produce the final result. Example of calculating the score for integer 5328. 1. 5^1 + 3^2 + 2^3 + 8^4 = 4118 2. And since 5328 is NOT PRIME the final result is 4118 - 2 = 4116. Example Execution #1 (see above): Enter your number: 5328 The final result of the input 5328 is: 4116 Example Execution #2 (score is 2620, add 7 because 3067 is prime): Enter your number: 3067 The final result of the input 3067 is: 2627 Example Execution #3: Enter your number: 345634591 The final result of the input 345634591 is: 43130635

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!