1.1 --- a/samples/composition/src-api2.0-enum/api/Arithmetica.java Sat Jun 14 10:04:51 2008 +0200
1.2 +++ b/samples/composition/src-api2.0-enum/api/Arithmetica.java Sat Jun 14 10:04:53 2008 +0200
1.3 @@ -49,6 +49,10 @@
1.4
1.5 private int sumRange1(int from, int to) {
1.6 int len = to - from;
1.7 + if (len < 0) {
1.8 + len = -len;
1.9 + from = to;
1.10 + }
1.11 int[] array = new int[len + 1];
1.12 for (int i = 0; i <= len; i++) {
1.13 array[i] = from + i;
1.14 @@ -57,6 +61,6 @@
1.15 }
1.16
1.17 private int sumRange2(int from, int to) {
1.18 - return (from + to) * (to - from + 1) / 2;
1.19 + return (from + to) * (Math.abs(to - from) + 1) / 2;
1.20 }
1.21 }