Permalink
Browse files

RootSample - add RootTerm with support for perfect squares

  • Loading branch information...
bobbymcr committed Aug 27, 2018
1 parent d84c3a7 commit c1064724a6cf65ecd8a9fadbce612d1740a56f18

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,20 @@
// <copyright file="RootTerm.cs" company="Brian Rogers">
// Copyright (c) Brian Rogers. All rights reserved.
// </copyright>
namespace RootSample
{
using System;
public struct RootTerm
{
private readonly int n;
public RootTerm(int n)
{
this.n = (int)Math.Sqrt(n);
}
public override string ToString() => this.n.ToString();
}
}
@@ -0,0 +1,25 @@
// <copyright file="RootTermTest.cs" company="Brian Rogers">
// Copyright (c) Brian Rogers. All rights reserved.
// </copyright>
namespace RootSample.Test
{
using FluentAssertions;
using Xunit;
public sealed class RootTermTest
{
[Theory]
[InlineData(0, "0")]
[InlineData(1, "1")]
[InlineData(4, "2")]
[InlineData(9, "3")]
[InlineData(65536, "256")]
[InlineData(1073741824, "32768")]
[InlineData(2147395600, "46340")]
public void PerfectSquares(int n, string expected)
{
new RootTerm(n).ToString().Should().Be(expected, "sqrt({0}) is {1}", n, expected);
}
}
}

This file was deleted.

Oops, something went wrong.

0 comments on commit c106472

Please sign in to comment.