Pronic numbers

Number to be said pronic number if it is the product of two consecutive integers.


Write a program to determine Pronic numbers

For Example

Input 
72

Output 
Pronic numbers

72 = 9 x 8

Solution:

using System;

namespace PronicNumber
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine("Enter the number:");
            var n = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine(IsPronicNumber(n) ? "Pronic Number." : "Not Pronic Number.");
            Console.ReadLine();
        }

        static bool IsPronicNumber(int num)
        {
            var isPronicNumber = false;

            for (var i = 1; i <= num; i++)
            {
                if ((i * (i + 1)) != num) continue;
                isPronicNumber = true;
                break;
            }
            return isPronicNumber;
        }
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *