Int16 - FactorOf

An Int16 extension method that indicates whether the value is a foctor of the specified number.

Try it

public static void Main()
{	
	short factorNumber = 1000;
	
	Console.WriteLine("Factor of {0} are:\n", factorNumber);

    for (Int16 val = 1; val <= factorNumber; val++)
    {
		// C# Extension Method: Int16 - FactorOf
		if(val.FactorOf(factorNumber))
		{
        	Console.WriteLine(val);
		}
    }
}

View Source
using System;

public static partial class Extensions
{
    /// <summary>
    ///     An Int16 extension method that factor of.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <param name="factorNumer">The factor numer.</param>
    /// <returns>true if it succeeds, false if it fails.</returns>
    public static bool FactorOf(this Int16 @this, Int16 factorNumer)
    {
        return factorNumer%@this == 0;
    }
}