Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

Truncatabel prime

17/10/2020 Client: arwaabdullah Deadline: 2 Day

  


Assignment 4: Truncatable Primes


Background


A left-truncatable prime number is one where the numbers resulting from removing the left-most digits are also prime. For instance, the number 9137 is a left-truncatable prime since 9137, 137, 37 and 7 are all prime.


A right-truncatable prime number is similarly defined, but removes a digit from the right. For example, 31193 is a right-truncatable prime since 31193, 3119, 311, 31, 3 are all prime.


A truncatable prime, also known as a two-sided prime, is one that is both left-truncatable and right-truncatable simultaneously. An example of such a prime is 3797.


We will be writing a program to explore these truncatable primes.


As a side note, the property of truncatable is dependent upon the base that the number is represented in. For this program, only worry about base 10.


Analysis


First note that the property of truncatability always produces a chain of numbers that terminate in single digit prime numbers. Therefore we can identify prime numbers by starting at the end of that chain and build numbers by adding digits. That is, we should be able to identify 3797 as a truncatable prime by building it from the right as in 7, 97, 797, then 3797, all the while verifying each step is left-truncatable.


Next note that when building from the right, we can only add odd digits. If we were to add a 0, 2, 4, 6, or 8, the resulting number would be divisible by 2 and thus not prime.


Finally, all of the single digit prime numbers are 2, 3, 5, and 7. These form the basis of our search.


Approach


Based upon the analysis above, we can find truncatable primes by building primes that are right-truncatable by construction, and verify they are left truncatable as we go. This suggest the following recursive algorithm




Build Truncatable Primes(int start)


if (start is not prime)


return


if (start is left truncatable)


found one. print it out


Build Truncatable Primes (start * 10 + 1)


Build Truncatable Primes (start * 10 + 3)


Build Truncatable Primes (start * 10 + 7)


Build Truncatable Primes (start * 10 + 9)


For left-truncatable, consider testing the number 12345. We know that we need to check 12345, 2345, 345, 45, and 5. But since all must be prime, the order they are tested in does not matter. In particular, we can check them in the order 5, 45, 345, 2345, 12345. What is nice about that order is we can get those digits by modding by successive powers of 10. Therefore you can use a loop that starts at 10, and updates by multiplying by 10.


Tips


· Start by writing an is_prime function.


· Next write an is_left_truncatable function.


· Using the modulus operator with powers of 10 can cut off digits from the left side.


· Write the algorithm specified above.


· Start the algorithm with all possible single digit prime numbers.


Sample Output




The truncatable primes are:


2


23


3


313


3137


317




37


373


3797


5


53


7


73


739397


797

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

Quality Homework Helper
Buy Coursework Help
Essay Writing Help
Online Assignment Help
Top Writing Guru
Top Grade Essay
Writer Writer Name Offer Chat
Quality Homework Helper

ONLINE

Quality Homework Helper

Hi dear, I am ready to do your homework in a reasonable price.

$42 Chat With Writer
Buy Coursework Help

ONLINE

Buy Coursework Help

Hi dear, I am ready to do your homework in a reasonable price.

$42 Chat With Writer
Essay Writing Help

ONLINE

Essay Writing Help

I am a qualified and experienced Writer, Researcher, Tutor, analyst and Consultant. I hold MBA (Strategic Management) (Finance and Marketing) & CPA.K (Accounting and Finance.)

$42 Chat With Writer
Online Assignment Help

ONLINE

Online Assignment Help

Hi dear, I am ready to do your homework in a reasonable price.

$35 Chat With Writer
Top Writing Guru

ONLINE

Top Writing Guru

I am an Academic writer with 10 years of experience. As an Academic writer, my aim is to generate unique content without Plagiarism as per the client’s requirements.

$40 Chat With Writer
Top Grade Essay

ONLINE

Top Grade Essay

Working on this platform from a couple of time with exposure of dynamic writing skills gathered with years experience on different other websites.

$42 Chat With Writer

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

Star wars episode 2 dorme - Managerial Epidemiology Week 3 Discussion - The theme of the fur coat - Alpha vets burry port - Red bull case analysis - Wake duncan with thy knocking meaning - Lateral lisp butterfly technique - Series and parallel circuits physics classroom - Paul revere's ride summary - Sorensen systems inc is expected to pay - Work breakdown structure of restaurant - Learn labview in 6 hours - Discussion - Kepnock state high school - 3.1&3.2 Discussion: Devotional Reflection-Children of Light-Transparency & Borland Case Final Response - School leaving age victoria - Bite fingernails psychology - Biodegradable plastic bags business plan - Paper - Design an algorithm - Life after death presentation - Patterson river vet clinic - Ed traut prophecy south africa - How is the total magnification of a microscope calculated - List of media codes and conventions - Hygs yahoo finance - Important composers of the romantic period - Window of tolerance worksheet - Assignment 1 reviewing research and making connections - Oscar cinematographer jurassic world crossword - Psychological Factors - Gematrix the elite code - Ac current amplifier circuit - Division 293 notice of assessment - John steinbeck the chrysanthemums pdf - Quality Improvement - The most beautiful thing short film - Write an ethnography essay focused on a particular group of people and the routines or practices that best reveal their unique significance as a group. - 16 bit word length - International capital market - Deakin late submission policy - Children’s Health Fund and National Breast Cancer Coalition (Due 48 hours) - Abstract algebra a first course 2nd edition by dan saracino - Woodville day nursery & kindergarten - How you do anything is how you do everything quote - The crucible text response - Essentials of business law 6th edition pdf - Monash jd deferred exam - Fat soluble vitamins powerpoint presentation - Niosh lifting equation excel - 1- Write 2 paragraphs about your opinion of using these methods in writing. 2- Critically read and annotate Nancy Mairs essay entitled, "Disability"pg. 12 Write a one page essay answering these questions and addressing these issues - BPSC 021 - Fall 2020 - Pharmasim highest stock price - Managerial hubris and ethical decision making - Drinking coffee elsewhere by zz packer pdf - Zelda zanders singing in the rain - GLORIA TAPES CRITIQUE - Bino the elephant theme song - Assassin's creed 3 benjamin franklin pages reward - Final exam - Moral issues in business shaw pdf - IT incident response - Fair is foul and foul is fair quote - Chaplinsky v new hampshire case brief - Fontana white chocolate mocha sauce world market - Practical connection assignment - Sue klebold my son was a columbine shooter - How to calculate fe from fe2o3 - Responses - Loss minimization in insurance - Health point garden city - Highly brill leisure center swot analysis - Data Analysis and Quality Improvement Initiative (1*3) - Durban's finest??(((((0835179056))??$$abortion pills for sale in durban north mkondeni Ashdown chesterville NAMIBIA Botswana kwazulu_natal - Policy - Xcix in roman numerals - Coldfusion get ip address - Apiweb.biomerieux.com - Characteristics of youth culture - Budget Cycle - Iris diaphragm microscope function - Avon community employment support centre - Size of a2 paper cm - Aldo leopold a sand county almanac sparknotes - Boral terracotta shingle roof tiles - 0417 12 m j 16 ms - Can g6pd eat almonds - Training and development mcdonalds - Increase Sales Plan for Small Business - Cuhk nursing admission score - Heinemann chemistry 1 vce sb eb 5e - Woke up half dressed still buzzin - Escience lab 3 answers - General parasitology lecture notes - Bad back posture homework - Dive into the Addictive World of io Games: Your Ultimate Guide to Online Multiplayer Mayhem! - Discussion - Peterborough utilities water bill - Flames and dangling wire - Tens digit that is 8 more