|
|
well then.
and i felt sorry for him having to find them on his own.
well observed!
|
|
|
|
|
- Pascal - wrote: wikipedia stops at 113 too
13 is considered bad unlucky number. Is 113 fall under this category also?
|
|
|
|
|
Interesting how many unproved conjectures there are.
Kevin
|
|
|
|
|
That would be one heck of a long list if they (the original coder or Wikipedia) attempted listing all the primes
Rob G
|
|
|
|
|
And, in addition to being very limited in the range of input values, the result isn't correct, either.
<SmartassMode>
1 is not a prime number, by definition.
</SmartassMode>
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
True, but that did not worry me.
|
|
|
|
|
mav.northwind wrote: 1 is not a prime number, by definition.
It is qualified as Unique Number right?
|
|
|
|
|
|
dbrenth wrote: The first 10000 prime numbers[^]
And any of the following things would have happened for sure:
1) Typing the if-else clause for 10000 numbers, he would broken the keyboard.
2) Typing the if-else clause for 10000 numbers, he would have broken down and ambulance should have been requested.
It is an unnecessary headache, at least in this case right?
|
|
|
|
|
Ask him to write a function that returns weather or not a given number is even
|
|
|
|
|
Well funny you should mention that, since it was asked previously.
Amazingly enough, most knew the *hidden* patterns of even numbers.
Or they heard me say modulus, between all the words that sent them to sleep.
|
|
|
|
|
Giorgi Dalakishvili wrote: Ask him to write a function that returns weather or not a given number is even
And for sure, the developer would written the code which would have thrown System.StackOverFlowException
|
|
|
|
|
How about a function that returns whether a number is an integer?
Chris Meech
I am Canadian. [heard in a local bar]
|
|
|
|
|
|
I really feel sorry for him...
I hope u might not have scold that poor guy
Regards
Anil
|
|
|
|
|
Nah, since for most of their test data it returned good results.
|
|
|
|
|
Waaaay back in college, in my first Pascal class, we were assigned the task of writing a program to perform the "Sieve of Eratosthenes"... but the assignment quoted a formula to use... which was faulty (of course). I don't know what the other students did, but I headed to the library.
If I ever teach (and I'd like to) I would assign the problem with extra credit to whomever builds the largest sieve. Wouldn't this be a good Friday programming quiz?
|
|
|
|
|
PIEBALDconsult wrote: Wouldn't this be a good Friday programming quiz?
I miss those.
I leave my office a bit early on Friday evenings and don't get to see the Friday quizzes because they're posted later in the day. (I don't have a computer at home.)
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
He does not need any computer to find prime numbers
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
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[^]
|
|
|
|
|
I dunno, maybe a switch statement.
|
|
|
|
|
Don't you just love infinate loops?
|
|
|
|
|
(Pssst, I think he used a <, but didn't remember to use < when he posted.)
-- modified at 20:41 Thursday 14th June, 2007
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;
But you're right, it lacks i++ .
|
|
|
|
|
That is again Horror Coding
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|