Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My problem consists of 3 functions that output yes or no if a number is a palindrome, near prime, or a nice number. The direction

My problem consists of 3 functions that output yes or no if a number is a palindrome, near prime, or a nice number. The direction below apply the fucntions to a score which I am unable to do.

You will be given a list of numbers. Each number is assigned a score. Its score is determined as follows:

A numbers base score is the value of the number itself.If the number is a palindrome it scores is doubled. If the number is a prime its score is doubled. If the number is a nice number its score is tripled.

Consider how to determine the score of a number 89. It is not a palindrome and but it is nice and near prime:

Base score: 89 Score after palindrome check: 89 (remains same as not a palindrome) Score after prime check: 188 (doubled as 89 is prime) Score after nice check: 534 (tripled as 89 is nice)

Consider the number 101: It is a palindrome, it is prime but it is not a nice number: Base score: 101 Score after palindrome check: 202 (doubled as its a palindrome)Score after prime check: 404 (doubled as 101 a prime) Score after nice check: 404 (not tripled as 101 is not nice)

Given a list of numbers entered by the user output the list of numbers in sorted order (ascending) of their scores. Also include the score achieved with each number separated by a comma after the number.

For example if the user enters 89 101 You have to output

101,404 89, 534

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Bioinformatics Databases And Systems

Authors: Stanley I. Letovsky

1st Edition

1475784058, 978-1475784053

More Books

Students also viewed these Databases questions

Question

=+ What are the efficiency levels and growth potentials of

Answered: 1 week ago

Question

Describe the economic model that is proposed for the operation.

Answered: 1 week ago