Skip to content

Instantly share code, notes, and snippets.

@EBojilova
Created April 26, 2015 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EBojilova/25835c1f77a948a1f3bf to your computer and use it in GitHub Desktop.
Save EBojilova/25835c1f77a948a1f3bf to your computer and use it in GitHub Desktop.
02.Peters Game
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class PetersGame
{
static void Main(string[] args)
{
ulong start = ulong.Parse(Console.ReadLine());
ulong end = ulong.Parse(Console.ReadLine());
string word = Console.ReadLine();
BigInteger sum = 0;
for (ulong i = start; i < end; i++)
{
if (i%5==0)
{
sum += i;
}
else
{
sum += i % 5;
}
}
var sumSymbols = sum.ToString();
if (sum % 2 ==0)
{
var first = sum.ToString().ToCharArray().First();
sumSymbols = sumSymbols.Replace(first.ToString(), word);
}
else
{
var last = sum.ToString().ToCharArray().Last();
sumSymbols = sumSymbols.Replace(last.ToString(), word);
}
Console.WriteLine(sumSymbols);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment