WSQ08 – Yo Soy 196

The Magic Numbers flickr photo by K & P shared under a Creative Commons (BY-NC-ND) license

Background

Lychrel numbers are natural numbers that do not form a palindrome after successive additions to their inverse. See details on Wikipedia: http://en.wikipedia.org/wiki/Lychrel_number

What to Do

Your job is to create a program that asks the user for two pieces of data:

  • The lower bound of the sequence
  • The upper bound of the sequence
Then you check the values from the lower bound (inclusive) to the upper bound (inclusive) and make a report of them. During the analysis of each number, if a Lychrel number is found it should be reported immediately with something like “Found a Lychrel number: 196”

Details

The report must show:
  • The range of numbers analysed (lower to upper bound)
  • The number of natural palindromes (no addition to inverse needed)
  • The number of non-Lycherels encountered (become palindromes)
  • The number of Lycherel number candidates (that did not converge to palindrome)

Since you will not be able to prove that a number is Lycherel (since you cannot computer forever to check), our definition for a Lycherel candidate will be if a number does not converge after 30 iterations of applying the addition to the inverse.

To get this working well, you will need support for Big Integers. You can base your solution off my codebase on GitHub. Unzip all of the files in a directory and use the command “make” to compile. Run the executable.

How to use BigInteger and make

Video Demo

What to Submit

As usual, create a blog post explaining what you did, where you found resources (books, videos, web pages, friends) to help you solve this. Remember to put the tag #WSQ08  on your post so our blog hub picks that up.

You should include your code as a link to GitHub. You really should start using your GitHub repository now. If you need help on that, just ask Ken or your classmates.

And of course, leave any questions here as well as in our TC1017 Facebook group so we all see your question posted there.

Feature Image Credit

The Magic Numbers flickr photo by K & P shared under a Creative Commons (BY-NC-ND) license

CC BY-SA 4.0 WSQ08 – Yo Soy 196 by Bauer Ken is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

One thought on “WSQ08 – Yo Soy 196

Comments are closed.