Jump to content

Search the Community

Showing results for tags 'prime'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Location


WWW


Interests

Found 1 result

  1. #region Required project assemblies using System; #endregion namespace IsPrimeNumber { internal class Program { private static bool IsPrimeNumber(int number, out int divisibleBy) { divisibleBy = -1; // Set the out parameter as -1, for those numbers which are prime values. if (number <= 1) { return false; // Return false if the value is less than or equal to one. } for (int i = 2; i <= Math.Sqrt(number); i++) { if (number % i == 0) { divisibleBy = i; // Set the out param as the divisible by value. return false; } } return true; // This means it's a prime number. } private static void Main() { int userChoice; do { Console.Write("Please enter an integer number to see if it's a prime number: "); Int32.TryParse(Console.ReadLine(), out userChoice); Console.WriteLine(); // New line. } while (userChoice <= 0); int numberDivisible; if (IsPrimeNumber(userChoice, out numberDivisible)) { Console.WriteLine("Your number is a prime value."); } else { if (numberDivisible == -1) { Console.WriteLine("Your number is NOT regarded as a prime value."); } else { Console.WriteLine("Your number is NOT a prime value as it's divisible by {0}.", numberDivisible); } } Console.WriteLine(); // New line. Console.WriteLine("Press any key to continue . . ."); Console.ReadKey(true); } } }
×
×
  • Create New...