at least he tried
-
Ask him to write a function that returns weather or not a given number is even :D
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
:-DVasudevan Deepak Kumar Personal Homepage Tech Gossips
-
as an assignment, i asked for a program that we've all been through, a function that returns weather or not a given number is prime. in one case, i was given the following :
if(num== 1 || num== 2 || num== 3 || num== 5 || num== 7 || num== 11 || num== 13 || num== 17 || num== 19 || num== 23 || num== 29 || num== 31 || num== 37 || num== 41 || num== 43 || num== 47 || num== 53 || num== 59 || num== 61 || num== 67 || num== 71 || num== 73 || num== 79 || num== 83 || num== 89 || num== 97 || num== 101 || num== 103 || num== 107 || num== 109 || num== 113)
{
return true;
}
else
{
return false;
}when i asked him why he stopped at 113 (since it was the only thing i thought of asking) he said, in a tired voice, "I couldn't think of any more numbers" do you, or do you not feel sorry for him?
me, myself and my blog - loadx.org ericos g.
He is a genius - always staying in business with a new update of primes!!
-
wikipedia stops at 113 too :) http://en.wikipedia.org/wiki/Prime_number[^]
Interesting how many unproved conjectures there are.
Kevin
-
Is this real c# code or just a joke? I don't know the language but it looks pretty ugly to me...
We're in the pipe, five by five - Terran dropship.
Yes, just formatted "my way".
-
Yes, just formatted "my way".
yowch! Glad I don't have to maintain any of your code.
-- You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
-
That is again Horror Coding :laugh:
Regards, Sylvester G sylvester_g_m@yahoo.com
Your nick is a coding horror by itself! Make it small like all the other please :)
**
xacc.ide-0.2.0.75 - now with C# 3.5 support and Navigation Bar!
**
-
yowch! Glad I don't have to maintain any of your code.
-- You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
Back atcha!
-
as an assignment, i asked for a program that we've all been through, a function that returns weather or not a given number is prime. in one case, i was given the following :
if(num== 1 || num== 2 || num== 3 || num== 5 || num== 7 || num== 11 || num== 13 || num== 17 || num== 19 || num== 23 || num== 29 || num== 31 || num== 37 || num== 41 || num== 43 || num== 47 || num== 53 || num== 59 || num== 61 || num== 67 || num== 71 || num== 73 || num== 79 || num== 83 || num== 89 || num== 97 || num== 101 || num== 103 || num== 107 || num== 109 || num== 113)
{
return true;
}
else
{
return false;
}when i asked him why he stopped at 113 (since it was the only thing i thought of asking) he said, in a tired voice, "I couldn't think of any more numbers" do you, or do you not feel sorry for him?
me, myself and my blog - loadx.org ericos g.
-
Your nick is a coding horror by itself! Make it small like all the other please :)
**
xacc.ide-0.2.0.75 - now with C# 3.5 support and Navigation Bar!
**
Thank you sir ..I did that...
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[^]
MSVC++ generates an error on the above code.;) // why not having then: int Primes[]={2,3,5,7,...};:rolleyes:
-
wikipedia stops at 113 too :) http://en.wikipedia.org/wiki/Prime_number[^]
That would be one heck of a long list if they (the original coder or Wikipedia) attempted listing all the primes ;) Rob G