Skip to content

Instantly share code, notes, and snippets.

@Chuzzy
Last active September 14, 2016 14:03
Show Gist options
  • Select an option

  • Save Chuzzy/e588549473bd4230da6ed0217be83b50 to your computer and use it in GitHub Desktop.

Select an option

Save Chuzzy/e588549473bd4230da6ed0217be83b50 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SumOfDigitsSequence
{
class Program
{
static ulong Sum(List<ulong> nums)
{
ulong result = 0;
foreach (ulong number in nums)
{
string strNumber = number.ToString();
foreach (char digit in strNumber)
{
switch (digit)
{
case '0':
break;
case '1':
result += 1;
break;
case '2':
result += 2;
break;
case '3':
result += 3;
break;
case '4':
result += 4;
break;
case '5':
result += 5;
break;
case '6':
result += 6;
break;
case '7':
result += 7;
break;
case '8':
result += 8;
break;
case '9':
result += 9;
break;
default:
break;
}
}
}
return result;
}
static void Main(string[] args)
{
List<ulong> numbers = new List<ulong>();
numbers.Add(1);
numbers.Add(1);
for (int i = 0; i < 250000; i++)
{
for (uint j = 0; j < 4000000000; j++)
{
ulong num = Sum(numbers);
numbers.Add(num);
}
}
ulong total = Sum(numbers);
Console.WriteLine("Total is " + total);
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment