You can try using Python with variable declarations:
>>> x = 0
>>> def fact(n):
... x = 0
... z = 1
... for i in range(1, n + 1):
... z = z * i
... return z
...
>>> x = 5
>>> fact(x)
120
Can you explain what the problem is with this? Also, as Nick Bastin said in a comment, this will help if you explain if your issue is related to an ad or an area.
If your problem is with syntax or static typing, would the following syntax be acceptable to you?
def f(double x):
return x**2-x
def integrate_f(double a, double b, int N):
cdef int i
cdef double s, dx
s = 0
dx = (b-a)/N
for i in range(N):
s += f(a+i*dx)
return s * dx
This syntax applies to Cython , a language for extending Python using compiled (C) extensions.