/* https://puzzlefry.com/puzzles/easy-but-tricky-math-riddle/ """ Can you solve this? 2 = 5 3 = 12 4 = 28 5 = ?? """ According to one comment (same links as above) it's: """ 2 = 5 [2^2 + (2^0) ] 3 = 12 [3^2 + (3^1 x 2^0)] 4 = 28 [4^2 + (2^2 x 3^1)] 5 = 133 [5^2 + (3^2 x 2^2)] For even number n = n^2 + (2^n-2 x 3^n-3) for all n>2 For odd number n = n^2 + (3^n-2 x 2^n-3) for all n>1 """ Expanded version: 0 0 2 5 2 5 3 12 3 12 4 28 4 28 5 ? Nope, this seems to be too hard to find out... */ data(puzzle2,Data,Vars,Unknown,Ops,Constants,MaxC) :- Expanded = true, Ops = new_map([infix=["+","*","mod"], op1=["even","odd"], user=["pow"], user3=["if_then_else"], conditions=["=="] ]), Constants = 0..3, MaxC = 15, % get_global_map().put("debug",true), if Expanded then Data = [ [[0,0,0,0,2],5], [[0,0,2,5,3],12], [[2,5,3,12,4],28] ], Vars = ["A","B","C","D","E"], Unknown = [3,12,4,28,5] % Data = [ [[0,0,2],5], % [[2,5,3],12], % [[3,12,4],28] % ], % Vars = ["A","B","C"], % Unknown = [4,28,5] else Data = [ [[2],5], [[3],12], [[4],28] ], Vars = ["A"], Unknown = [5] end.