Ejemplo n.º 1
0
    static void     Main(string[] args)
    {
        // Hi Steven.
        // Hi Tariq and Murali; oh, and hello World!
        ///////////// FOR PRIMES ////////////////////
        // Ask user how many primes they want.
        System.Console.WriteLine("Please input the number you want to check up to. (Must be above 3.)");
        int prime = System.Convert.ToInt32(System.Console.ReadLine());

        // For regular for loop Prime Generator.
        //PrimeGenerator gen = new PrimeGenerator();
        //gen.PrintPrimes(prime);

        // For Sieve Algorithm Generator
        SieveGenerator sieve = new SieveGenerator();

        sieve.PrintPrimes(prime);         // Prime MUST be greater than 3 for this to work.

        //////////////////////////////////////////////////////////


        /////////////// FOR DIGITS /////////////////
        System.Console.WriteLine("Please enter a number so we can break it down into its digits.");
        int digits = System.Convert.ToInt32(System.Console.ReadLine());

        NumberOps num = new NumberOps();

        num.PrintDigits(digits);
        ///////////////////////////////////////////////////////
    }
Ejemplo n.º 2
0
    public void NumberOTest()
    {
        NumberOps num = new NumberOps();

        ////////////////////////////////////////////////////////////
        // Check if the digits are correct
        int        number = 123459876;             // Our test number.
        List <int> Digits = num.GetDigits(number); // Get a list of the digits from our method in NumberOps.cs

        int GeneratedNumber = 0;                   // All of the digits will be added to the number.

        for (int c = 0; c < Digits.Count; c++)
        {
            GeneratedNumber = GeneratedNumber + Digits[c] * num.PowerOfTen(c);
        }

        if (GeneratedNumber != number)
        {
            throw new Exception("Digit check failed.");
        }

        ////////////////////////////////////////////////////////////
    }