From 896f7690b8d9eef0e65f17eb6cc52a5945b32c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Blanc?= <regwblanc@gmail.com> Date: Thu, 29 Nov 2012 17:25:50 +0100 Subject: [PATCH] fast exponentiation from comfusy, would be interesting to support --- testcases/synthesis/FastExp.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 testcases/synthesis/FastExp.scala diff --git a/testcases/synthesis/FastExp.scala b/testcases/synthesis/FastExp.scala new file mode 100644 index 000000000..9ea39a1d6 --- /dev/null +++ b/testcases/synthesis/FastExp.scala @@ -0,0 +1,15 @@ +import leon.Utils._ + +object FastExp { + + def fp(m : Int, b : Int, i : Int) : Int = i match { + case 0 => m + case 2 * j => fp(m, b*b, j) + case 2 * j + 1 => fp(m*b, b*b, j) + } + + def pow(base: Int, p: Int) = { + fp(1, base, p) + } + +} -- GitLab