- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
More functions should disregard input values and just return 12. It would make life easier.
Admin
No No, it's not twelve. 'i' gets modified in the loop. So, we have a function that returns the answer to life, the universe, and everything.
Admin
Admin
Likely the submission was altered slightly to make it do just that, but it's pretty awesome nonetheless.
Sadly, when I got out of college no one really expected much from me even though the college I went to stressed things like team work and not breaking the build. :P
Admin
Doesn't use the input parameter and doesn't reuse the variable a, except to hold the number. Course, we all were dumb at one point, but at least we know what recursion was when we graduated.
Admin
Yes we know it is modified in the loop. That's why it is twelve and not 10.
Admin
Yes it is twelve. First loop i = 1. i = 1 * 2 = 2, then the i is incremented to 3. Next loop i = 2. i = 3 * 4 = 12, 12 is > 10 so the loop ends. QED
Admin
Whoops, that should be i = 3 on the second line
Admin
Graduates who don't know what recursion is are less common than forum users who don't know how C-style for loops work, I guess.
Admin
This is shocking. I just recently graduated, and I am shocked at that code, I especially love his manipulation of 'i' in the loop and not using the all important 'n' what so ever ..amazing!
Admin
Are you saying that n! != 12 for all n?
Admin
I just find it amazing that people who code like that can actually graduate!
Admin
Admin
I used to interview candidates at my previous job. Often asked this question. Have to say this candidate is in the top 50 percent... :)
Admin
My former boss asked a person he was interviewing what the definition of a 'class' was in reference to c++... They responded with "A class is what I attended at school to learn about c++". The didn't get hired...
Admin
Admin
I never regurgitated from college, hell I never went, and even I know what recursion is.
Admin
Admin
Ha! Shows what you know: 3! = 12 (base 4) 4! = 12 (base 22) 5! = 12 (base 118)
On a related note, does anyone want to solve for z in G(z) = 12 where G is the Gamma function? Because that's like a factorial.
Admin
Dear god, why do people insist on reinventing the wheel? We REJECT candidates who use their own sort algorithms in their homework assignment.
Admin
Admin
Oh, of course they found jobs. Jobs where you ask "Do you want fries with that?" and give the customer exactly 12 fries, no matter how big a serving they wanted.
Admin
And 2! = 12 (base... uh, 0?)
Admin
Same here. I'm a f'ing high school student and even I know what recursion is.
Oh, and by the way:
Admin
He could have made it interesting by throwing in a "+i* (i % 2 == 0 ? -1 : 1)" or something.
Admin
He could have made it interesting by throwing in a "+i* (i % 2 == 0 ? -1 : 1)" or something.
Admin
I pity the guy who wrote that. He spend possibly several years of his life, trying to learn something that would keep him fed throughout the rest of his life, but he didn't learn anything. He is completely useless now. That's a very depressing thought.
Admin
Written in a minute or two by myself, with no reference to anything:
Recursion! Factorials! Rubbish, but actually works! Doesn't return twelve!
Unfortunately, I didn't study computer science at university - in fact, I have no computing qualifications whatsoever. Sorry.
Admin
Admin
I pitty the university and future people that apply for jobs out of said school. He is clearly a reflection of the program and how anyone can pass.
Colleges are allowing too many students to move forward these days and there are far too few courses that weed out the weak. Infact, a Comp Sci 101 course should have been enough to address this
Admin
Isn't factorial(0) defined as 1?
Captcha: muhahaha!
Admin
I dunno if I agree that this guy is a reflection of how bad the school from which he graduated is.
I had plenty of difficult computer science classes in college, and I was just a computer science minor. Several people in several of my classes either failed or withdrew from the class half-way through because they just weren't getting it. Still, though those classes were good at weeding out the morons, a few exceptionally skilled slackers managed to make it through to their senior year. I got stuck with them on group projects. They were useless, lazy, and they didn't seem to know crap. How they managed to pass their previous classes was and still is beyond me.
Admin
Nice code. Will never return though...
Captcha: alarm - what this code raised internally (in me)
Admin
Some CS programs are really MIS programs in disguise. Don't be fooled!
Admin
But evidently you haven't gotten to the part about infinite loops yet.
Admin
LOL WTF?
It actually returns 13, because 12 is incremented one last time before the comparison.
Admin
At least the code in the story produces an answer when n > 1 ;)
Admin
Congratulations! You have just discovered Infinite Recursion (TM), or more commonly known as the stack overflow.
Admin
Admin
Ooops, but it isn't stored though =/
Admin
Well, but at least he knew what a factorial is! (mostly...anyway)
Admin
In other words, perfect management material... from here its all up up up the ziggurat lickity split!
Admin
Here's the (obviously) corrected version in Python:
Admin
4.5224! = 12
Admin
Quite right. Looks like I needed to sleep some more last night!
Admin
Garbage In - Garbage Out
I sat behind a girl in my Comp Sci classes who declared to the entire class that multiplying a positive number by a negative number yielded a positive number.
How can you expect to build a competent computer scientist on that kind of foundation? Imagine what she cranked out for recursive algorithms.
Admin
Admin
Sorry about that, gamma(4.5224) = 12, so:
3.5224! = 12
My bad.
Admin
Admin
Damn, misread the code myself. This is what happens when I try to debug before caffeine.