Any one liner code ?
public static void main()
{
//looking better code below problem
//the house numbers along jefferson street 1 through 120.
//how many digits there house numbers..
int digitcount = 0;
(int = 1; <= 120; i++) digitcount += i.tostring().length;
console.writeline(digitcount);
}
{
//looking better code below problem
//the house numbers along jefferson street 1 through 120.
//how many digits there house numbers..
int digitcount = 0;
(int = 1; <= 120; i++) digitcount += i.tostring().length;
console.writeline(digitcount);
}
you use:
int digitcount = enumerable.range(1, 120).sum(i => i.tostring().length);
reed copsey, jr. - http://reedcopsey.com
if post answers question, please click "mark answer" on post , "mark helpful".
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment