For the first digits of pi:
3.1415926535897932384626433832795028841971693993751
after removing any non-numbers it become
31415926535897932384626433832795028841971693993751
This number has 50 digits in them which means there is 50*50 pairs = 2500
but i don't need ALL pairs, for example (a, b) and (b, a) is a repeating pair so I need to neglect that.
so the formula to find the pairs that will be calculated is:
(50 * (50-1))/2 = 1,225 this means that there will be 1225 unique pairs that I need to check if they match or not.
so first I start with 2 digits repeating numbers which are any numbers starting from 00 to 99 (100 options).
because we are doing 2 digits, then in a number of length "50", there is 49 double digit numbers. e.g.:
(31, 14, 41, 15, 59, 92, 26, 65, 53, 35, 58, 89, 97, 79, 93, 32, 23, 38, 84, 46, 62, 26, 64, 43, 33, 38, 83, 32, 27, 79, 95, 50, 02, 28, 88, 84, 41, 19, 97, 71, 16, 69, 93, 39, 99, 93, 37, 75, 51)
using (49) the number of unique pairs to test is: (49 * (49 - 1)) / 2 = 1176
so in the example above the first 2 digit pairs are (31, 14), then (31, 41), then (31, 15) all the way until we finish from the initial (31) and start from the second 2 digit number which is (14, 41) then (14, 15) etc... all the way to pair number "1176"
In this case given above, out of 1176 pairs there are 10 matches.
so if a person will input that number, the result formula should be "10"
after that we will do the same for 3 digit numbers, 4, 5, 6 etc...
so for 3 digits its the same, the pairs will be as follow:
314, 141, 415, 159, 592, 926, 265, 653, 535, 358, 589, 897, 979, 793, 932, 323, 238, 384, 846, 462, 626, 264, 643, 433, 338, 383, 832, 327, 279, 795, 950, 502, 028, 288, 884, 841, 419, 197, 971, 716, 169, 693, 939, 399, 993, 937, 375, 751
but this time since it's 3 digits, then in a number of 50 digits there will be only 48 triple digit numbers. so only "1128" pairs to test and match.
so basically the formula should have these inputs:
"input number"
"number of digits to test"
so a "31415926535897932384626433832795028841971693993751" with "2" will return "10"
and "31415926535897932384626433832795028841971693993751" with "3" will return "0" <- because there are no matches for this case...
Bookmarks