Example #1
0
		public P031 ()
		{
			var options = new ulong[] { 1, 2, 5, 10, 20, 50, 100, 200 };
			var sums = new Summation (options);
			for (uint i = 1; i <= 200; i++) {
				Console.WriteLine (sums.Create (i));
			}
		}
Example #2
0
			internal SingleSum (Summation parent, ulong u, bool isBase)
			{
				Parent = parent;
				N = u;

				if (isBase) {
					W.Add (new ulong[] { u });
				}

				var add = new List<ulong[]> ();
				foreach (var prime in parent._Bases) {
					SingleSum lu;
					if (parent.All.TryGetValue (u - prime, out lu)) {
						add.AddRange (lu.W.Select (w =>
							w.Concat (new[] { prime })
							.OrderBy (x => x)
							.ToArray ()));
					}
				}

				W.AddRange (add
					.GroupBy (a => string.Join (",", a))
					.Select (g => g.First ()));
			}