#Web designer
def factorial(x):
#-------------------------------------------------
#--- Code snippet from The Math Vault ---
#--- Calculate factorial (C) Arthur Smith 1999 ---
#-------------------------------------------------
result = str(1)
i = 1 #Thanks Adam
while i <= x:
#result = result * i #It's faster to use *=
#result = str(result * result + i)
#result = int(result *= i) #??????
result str(int(result) * i)
#result = int(str(result) * i)
i = i + 1
return result
print factorial(6)
class StandardMathematicsSystem(MathematicsSystem):
def __init__(self, ibase):
if ibase.getBase() != new (IntegralNumber, 2):
raise NotImplementedError
self.base = ibase.getBase()
def calculateFactorial(self, target):
result = new (IntegralNumber, 1)
i = new (IntegralNumber, 2)
while i <= target:
result = result * i
i = i + new (IntegralNumber, 1)
return result
print StandardMathematicsSystem.getInstance(new (InternalBase, new (IntegralNumber, 2))).calculateFactorial(new (IntegralNumber, 6))
Name:
Anonymous2007-05-25 20:50 ID:mHFMDOiL
>>40
you are both wrong, IVE READ SICP, everyone else hasnt'
HI, I'M PAUL GRAHAM, FOUNDER AND CEO OF Y COMBINATOR. I HAVE MADE MANY INSIGHTFUL STATEMENTS IN MY ESSAY ENTITLED "YOUR MOTHER AND THE 48 VERY SMART PEOPLE" AND WOULD LIKE TO THANK TREVOR BLACKWELL, ROBERT MORRIS AND JESSICA LIVINGSTON FOR HAVING READ DRAFTS OF THIS ESSAY, WHICH YOU WILL BE ABLE TO FIND WITH 21 OTHERS ESSAYS IN MY UPCOMING BOOK "HACKERS AND YOUR SISTER". I GUARANTEE IT.
def factorial(x)
print [n for n in range(2, x + 1)]
Name:
Anonymous2007-05-25 23:21 ID:r00B89jk
Hay guys, I think you just spread the enterprise meme to reddit.
Name:
redir2007-05-25 23:35 ID:TDz4ykBW
erm I meant:
def fact(x):
r = 1
for x in (n for n in range(1, 9 + 1)): r*=x
return r
damn hangover....
Name:
Anonymous2007-05-25 23:46 ID:p9Rnzt89
Web designer should be
def factorial(x):
#-------------------------------------------------
#--- Code snippet from The Math Vault ---
#--- Calculate factorial (C) Arthur Smith 1999 ---
#-------------------------------------------------
result = str(1)
i = 1 #Thanks Adam
while i <= x:
#result = result * i #It's faster to use *=
#result = str(result * result + i)
#result = int(result *= i) #??????
#result str(int(result) * i)
result = str(int(result) * i) #Thanks Anon
#result = int(str(result) * i)
i = i + 1
return result
print factorial(6)
Name:
Anonymous2007-05-26 0:53 ID:KQr4fWNP
>>49
Fail, web designers don't know the meaning of anonymous.
Also, 50GET.
Name:
Anonymous2007-05-26 1:17 ID:QVvIyB+F
mu?
Name:
Chris Rathman2007-05-26 2:54 ID:VUtNl2ok
Well, as long as you're replicating some of the Haskell examples, you can throw in:
<pre>
# Boy Scout Programmer
y = (lambda le:
(lambda f: f(f))
(lambda f:
le(lambda x: f(f)(x))))
fac = y(lambda f: lambda n: 1 if (n == 0) else n*f(n-1))
</pre>
Name:
Anonymous2007-05-26 3:10 ID:aZuUXba6
lol, reddit is full of fags now that half the digg userbase have joined them
http://programming.reddit.com/info/1tjui/comments/c1tlx6 I'd give this an upvote if I didn't know that nothing of value ever comes from 4chan and this therefore cannot possibly be original. Still, some funny stuff!
No original content? print "reddit == fags"
HI, I'M PAUL GRAHAM, FOUNDER AND CEO OF Y COMBINATOR. I HAVE MADE MANY INSIGHTFUL STATEMENTS IN MY ESSAY ENTITLED "YOUR MOTHER AND THE 48 VERY SMART PEOPLE" AND WOULD LIKE TO THANK TREVOR BLACKWELL, ROBERT MORRIS AND JESSICA LIVINGSTON FOR HAVING READ DRAFTS OF THIS ESSAY, WHICH YOU WILL BE ABLE TO FIND WITH 21 OTHERS ESSAYS IN MY UPCOMING BOOK "HACKERS AND YOUR SISTER". I GUARANTEE IT.