Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static Tuple<int, int> DigitalRoot(long num)
{
int mp = 0;
while (num > 9)
{
num = num.ToString().ToCharArray().Select(x => x - '0').Aggregate((a, b) => a * b);
mp++;
}
return new Tuple<int, int>(mp, (int)num);
}
static void Main(string[] args)
{
foreach (long num in new long[] { 123321, 7739, 893, 899998 })
{
var t = DigitalRoot(num);
Console.WriteLine("{0} has multiplicative persistence {1} and multiplicative digital root {2}", num, t.Item1, t.Item2);
}
const int twidth = 5;
List<long>[] table = new List<long>[10];
for (int i = 0; i < 10; i++)
table[i] = new List<long>();
long number = -1;
while (table.Any(x => x.Count < twidth))
{
var t = DigitalRoot(++number);
if (table[t.Item2].Count < twidth)
table[t.Item2].Add(number);
}
for (int i = 0; i < 10; i++)
Console.WriteLine(" {0} : [{1}]", i, string.Join(", ", table[i]));
}
}