Quantcast
basic programming - Beyond.ca - Car Forums
Results 1 to 4 of 4

Thread: basic programming

  1. #1
    Join Date
    Jan 2004
    Location
    Calgary, AB
    Posts
    62
    Rep Power
    0

    Default basic programming

    anybody know the algorithm for how to write a function that computes prime numbers? by the way it's for C programming.
    thanks!

  2. #2
    Join Date
    May 2003
    Location
    Calgary
    Posts
    711
    Rep Power
    21

    Default

    doesn't the prof tell you basically how you do it and all you have to do is convert the instruction to C? I remember that's basically how they taught it when i was doing cpsc.

  3. #3
    Join Date
    May 2002
    Location
    Calgary, Alberta
    My Ride
    (maah raahde)
    Posts
    5,799
    Rep Power
    44

    Default

    Easiest way (in pseudocode):

    Given X, where X is any number that needs to be computed,

    Y = X-1

    If X modulo Y != 0,
    increment a counter

    decrement Y, and loop until Y == 0

    If the counter == 1, it's a prime (X divisible only by 1 and itself).

    Otherwise it's not a prime.

    That should work.

  4. #4
    Join Date
    Sep 2003
    Location
    Calgary, AB
    My Ride
    rsx-s
    Posts
    335
    Rep Power
    21

    Default

    thanks a lot man

Similar Threads

  1. movie: BASIC

    By redline_13000 in forum Entertainment
    Replies: 8
    Latest Threads: 08-20-2003, 03:20 PM
  2. Programming Compustar 2WFMR

    By joejoe3 in forum Mechanical
    Replies: 2
    Latest Threads: 06-16-2003, 11:59 PM
  3. easy programming help pls!

    By szw in forum General
    Replies: 5
    Latest Threads: 03-10-2003, 04:53 PM
  4. Replies: 17
    Latest Threads: 02-06-2003, 10:04 PM
  5. Basic Tools

    By szw in forum Mechanical
    Replies: 13
    Latest Threads: 10-26-2002, 08:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •