simple and fun programs using java
- Lychrel number
File name: palennum.java
Summary: The reverse-and-add process produces the sum of a number and the number formed by reversing the order of its digits. For example, 56 + 65 = 121. As another example, 125 + 521 = 646.
Some numbers become palindromes quickly after repeated reversal and addition, and are therefore not Lychrel numbers. All one-digit and two-digit numbers eventually become palindromes after repeated reversal and addition.
About 80% of all numbers under 10,000 resolve into a palindrome in four or fewer steps; about 90% of those resolve in seven steps or fewer. Here are a few examples of non-Lychrel numbers:
56 becomes palindromic after one iteration: 56+65 = 121. 57 becomes palindromic after two iterations: 57+75 = 132, 132+231 = 363. 59 becomes a palindrome after 3 iterations: 59+95 = 154, 154+451 = 605, 605+506 = 1111
whereas some numbers like 196, 691 etc. doesn't resolve into a palindrome even after millions of iterations.
Source: https://en.wikipedia.org/wiki/Lychrel_number
- 4 Colour Theorem:
File name: randomestate.java
Summary: In a map, the regions can be colored using at most four colors so that no two adjacent regions have the same color', needs to be interpreted appropriately to be correct.