[LON-CAPA-cvs] cvs: loncom /homework/templates sampleexternal.problem

droeschl droeschl at source.lon-capa.org
Wed Jun 3 06:25:12 EDT 2015


droeschl		Wed Jun  3 10:25:12 2015 EDT

  Modified files:              
    /loncom/homework/templates	sampleexternal.problem 
  Log:
  The first testcase (0=1) caused infinite recursion with the consequence         
  that the server runs out of memory. fact(n) now returns 1 for n <= 1.
  However, this won't prevent deficient submissions to run into the same
  consequences.
  
  
Index: loncom/homework/templates/sampleexternal.problem
diff -u loncom/homework/templates/sampleexternal.problem:1.6 loncom/homework/templates/sampleexternal.problem:1.7
--- loncom/homework/templates/sampleexternal.problem:1.6	Mon May  6 12:21:27 2013
+++ loncom/homework/templates/sampleexternal.problem	Wed Jun  3 10:25:12 2015
@@ -3,8 +3,8 @@
 <script type="loncapa/perl">
 sub fact {
    my $n=shift;
-   if ($n==1) {
-      return $n;
+   if ($n<=1) {
+      return 1;
    } else {
       return $n*&fact($n-1);
    }




More information about the LON-CAPA-cvs mailing list