« Event 5: You Call that a Strong Password? | Main | Directory Experts Conference 2008 Agenda »

Event 6: Prime Time

This one was fun.  Although, I knew what a Prime number is, I don't think I've ever learned methods to find them.  The method I used is fine for a small number, but really wouldn't scale.

Advanced Event 6 in the Microsoft Scripting Games 2008.

   1: '*********************************************************************

   2: ' Script Name: Event6.vbs

   3: '     Version: 1.0

   4: '      Author: Perry Harris (PHactotum)

   5: '     Updated: 8:45 AM Tuesday, February 26, 2008

   6: '     Purpose: Solves the 2008 winter Scripting Games Advance 

   7: '              Event 6: Prime Time

   8: '              

   9: '       Usage: cscript Event6.vbs

  10: '       Notes: 

  11: '    Keywords: 

  12: '  versioning: 1.0  Original release

  13: '*********************************************************************

  14: Option Explicit

  15: Dim StopPoint,StartPoint,i,j

  16: Dim Primes

  17: StopPoint = 200

  18: StartPoint = 2

  19: redim Primes(StopPoint + 1)

  20: For i = StartPoint to StopPoint

  21:     Primes(i) = True

  22: Next

  23: For i = StartPoint to StopPoint

  24:     If Primes(i) = True then

  25:         WScript.StdOut.WriteLine i

  26:     End If

  27:         for j = i to StopPoint

  28:             If i*j <=StopPoint then Primes (i*j) = False

  29:         Next

  30: Next

  31:  

  32:     


Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on February 26, 2008 5:08 PM.

The previous post in this blog was Event 5: You Call that a Strong Password?.

The next post in this blog is Directory Experts Conference 2008 Agenda.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 4.1