fork download
  1. fun fact(n) =
  2. let
  3. (*INV: 0 <= i <= m and f = i! *)
  4. fun iter(m,f,i) =
  5. if (i = m) then f
  6. else iter(m,f*(i+1),i+1);
  7. in
  8. iter(n,1,0)
  9. end;
  10. fun perfect(n) =
  11. let
  12. fun addfactors(n) =
  13. let
  14. fun factor(i) = if (n mod i = 0) then i else 0;
  15. fun sum(f,i,j) =
  16. if (i > j) then 0
  17. else f(i) + sum(f,i+1,j)
  18. in
  19. sum(factor,1,n div 2)
  20. end
  21.  
  22. in
  23. (n = addfactors(n))
  24. end;
  25.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
6
compilation info
Traceback (most recent call last):
  File "/usr/lib/python3.5/py_compile.py", line 125, in compile
    _optimize=optimize)
  File "<frozen importlib._bootstrap_external>", line 735, in source_to_code
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "./prog.py", line 1
    fun fact(n) =
           ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.5/py_compile.py", line 129, in compile
    raise py_exc
py_compile.PyCompileError:   File "./prog.py", line 1
    fun fact(n) =
           ^
SyntaxError: invalid syntax

stdout
Standard output is empty