Posts

Showing posts from April, 2020

Magnanimous numbers | Rosetta Code | #21

URL to the problem page:  http://rosettacode.org/wiki/Magnanimous_numbers A magnanimous number is an integer where there is no place in the number where a + (plus sign) could be added between any two digits to give a non-prime sum. E.G. 6425 is a magnanimous number. 6 + 425 == 431 which is prime; 64 + 25 == 89 which is prime; 642 + 5 == 647 which is prime. 3538 is not a magnanimous number. 3 + 538 == 541 which is prime; 35 + 38 == 73 which is prime; but 353 + 8 == 361 which is not prime. Traditionally the single digit numbers 0 through 9 are included as magnanimous numbers as there is no place in the number where you can add a plus between two digits at all. (Kind of weaselly but there you are...) Except for the actual value 0, leading zeros are not permitted. Internal zeros are fine though, 1001 -> 1 + 001 (prime), 10 + 01 (prime) 100 + 1 (prime). There are only 571 known magnanimous numbers. It is strongly suspected, though not rigorously proved, th...

Esthetic numbers | Rosetta Code | #20

URL to the problem page:  http://rosettacode.org/wiki/Esthetic_numbers An esthetic number is a positive integer where every adjacent digit differs from its neighbour by 1. E.G. 12 is an esthetic number. One and two differ by 1. 5654 is an esthetic number. Each digit is exactly 1 away from its neighbour. 890 is not an esthetic number. Nine and zero differ by 9. These examples are nominally in base 10 but the concept extends easily to numbers in other bases. Traditionally, single digit numbers are included in esthetic numbers; zero may or may not be. For our purposes, for this task, do not include zero (0) as an esthetic number. Do not include numbers with leading zeros. Esthetic numbers are also sometimes referred to as stepping numbers . Find and display, here on this page, the base 10 esthetic numbers with a magnitude between 1000 and 9999 . #include   <iostream> using   namespace   std ; int   finddigits ( int   a )...

Palindromic gapful numbers | Rosetta Code | #19

URL to the problem page:  http://rosettacode.org/wiki/Palindromic_gapful_numbers Numbers that are (evenly) divisible by the number formed by the first and last digit are known as gapful numbers . Evenly divisible means divisible with no remainder. All one─ and two─digit numbers have this property and are trivially excluded. Only numbers ≥ 100 will be considered for this Rosetta Code task.       Example 1037 is a gapful number because it is evenly divisible by the number 17 which is formed by the first and last decimal digits of 1 03 7 . A palindromic number, when the number is reversed, is the same as the original number. Show (nine sets) the first 20 palindromic gapful numbers that end with: the digit 1 the digit 2 the digit 3 ··· ··· the digit 9 #include   <iostream> using   namespace   std ; int   finddigits ( int   a ) {      int  cnt =  1 ;    ...
My photo
Ercan Tomac
instagram.com/ercantomac