Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. at least he tried

at least he tried

Scheduled Pinned Locked Moved The Weird and The Wonderful
question
42 Posts 25 Posters 261 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Rage

    You are right, this is awful. Better is:

    int Primes[]={2,3,5,7,...,113};
    int size=sizeof(Primes[])/sizeof(Primes[0]);
    int i=0;
    while (i<size)
    {
    if (num==Primes[i]) return true;
    }
    return false;

    Last modified: 21hrs 3mins after originally posted --

    Constantly "Saving the day" should be taken as a sign of organizational dysfunction rather than individual skill - Ryan Roberts[^]

    B Offline
    B Offline
    Bogdan Apostol
    wrote on last edited by
    #41

    MSVC++ generates an error on the above code.;) // why not having then: int Primes[]={2,3,5,7,...};:rolleyes:

    Bornish

    1 Reply Last reply
    0
    • P Pascal 0

      wikipedia stops at 113 too :) http://en.wikipedia.org/wiki/Prime_number[^]

      R Offline
      R Offline
      Rob Grainger
      wrote on last edited by
      #42

      That would be one heck of a long list if they (the original coder or Wikipedia) attempted listing all the primes ;) Rob G

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups