using System;
using System.Data.Sql;
using System.Data.SqlTypes;
using System.Diagnostics;
public class CPlanets
{
	static readonly int[] tryPlanetCounts = {
		2, 3, 4
	};
	
	[SqlFunction]
    public static int Planets(int SunTeeth, int RingTeeth)
    {
		int planetCount = 0;
		if (SunTeeth < RingTeeth)
		{
			for (int index = 0; index < tryPlanetCounts.Length; index++)
			{
				int SR = SunTeeth + RingTeeth;
				if(0 == (SR % tryPlanetCounts[index]))				
				{
					Trace.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);
					planetCount = tryPlanetCounts[index];
					break;
				}
			}
		}
		return planetCount;
    }
	[SqlFunction]
	public static int PlanetTeeth(int SunTeeth, int RingTeeth)
	{
		int planetTeeth = 0;
		if (0 == ((RingTeeth - SunTeeth) % 2))
		{
			planetTeeth = (RingTeeth - SunTeeth) / 2;
		}
		return planetTeeth;
	}


};
