Prime No. Tester Program Competition RRS feed

  • General discussion

  • Hi! Friends

    I've come up with a excellent idea to start a competition on making a prime no. tester program in a GraphicsWindow. I've given a clue to you by making a program(surely not in a GraphicsWindow). Lets see who has the shortest, the most efficient and the best code. Here's the code:

    TextWindow.Write("Enter the no:")

    No = TextWindow.ReadNumber()

    Flag = 0

    For i = 2 To No - 1

       Remainder = Math.Remainder(No, i)

       If Remainder = 0 Then

       TextWindow.WriteLine(No + " is divisible by  " + i)

       Flag = 1



    If Flag = 1 Then

       TextWindow.WriteLine(No + " is not a prime no.")


       TextWindow.WriteLine(No + " is not a prime no.")





    Kaustubh Welankar, Pune, India

    Friday, June 18, 2010 3:27 PM

All replies

  • A couple of simple mods to speed it up for larger prime numbers, import LHK882.

    The mods find 7427466391 as prime almost instantly, the original takes several minutes before I stopped it.

    Friday, June 18, 2010 6:42 PM