Recursive function won't compile

B

bc1891

#include <stdio.h>
#include <stdlib.h>

def RecursiveFact(n):
if(n>1):
return n*RecursiveFact(n-1)
else:
return 1

fact = RecursiveFact(31)
print fact

fact = "End of program"
print fact


.......but yet it still gives the right answer. How is this possible?
 
D

dj3vande

(Subject: Recursive function won't compile)
#include <stdio.h>
#include <stdlib.h>

def RecursiveFact(n):
......but yet it still gives the right answer. How is this possible?

Possibly because it gives the right answer in a different language than
it fails to compile in?


dave
 
A

ajaksu

#include <stdio.h>
#include <stdlib.h>

def RecursiveFact(n):
    if(n>1):
        return n*RecursiveFact(n-1)
    else:
        return 1

fact = RecursiveFact(31)
print fact
The output is 8222838654177922817725562880000000 and is correct. But
the "#include"s tell me you're a bit confused. Have you tried running
"python yourscript.py" (where "yourscript.py" is the filename you
saved the above program to)?

HTH,
Daniel
 
D

Diez B. Roggisch

#include <stdio.h>
#include <stdlib.h>

def RecursiveFact(n):
if(n>1):
return n*RecursiveFact(n-1)
else:
return 1

fact = RecursiveFact(31)
print fact

fact = "End of program"
print fact


......but yet it still gives the right answer. How is this possible?

Given that you obviously don't use python, but some weird cross-breed
beteween python and C - who are we to judge the semantics of that chimera?

Diez
 
G

George Sakkis

(e-mail address removed) schrieb:








Given that you obviously don't use python, but some weird cross-breed
beteween python and C - who are we to judge the semantics of that chimera?

Diez

Seems like a bad belated April Fool's day joke to me.

George
 
K

Keith Thompson

Diez B. Roggisch said:
Given that you obviously don't use python, but some weird cross-breed
beteween python and C - who are we to judge the semantics of that
chimera?

What do you mean? Aren't these:

#include <stdio.h.
#include <stdlib.h>

perfectly valid comments in Python?

Followups redirected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top