/* 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 ? Generation 151 using [+,*,-,/,mod,\/,/\,^,even,odd,if_then_else,==], [program = D ^ (B == D) ^ D + 4,res = 60,count = 1] Generation 1432 using [+,*,-,/,mod,\/,/\,~,even,odd,if_then_else,==], [program = (5 - odd(C + D)) * (D - (3 * E - 7)),res = 100,count = 1] Generation 868 [program = if_then_else(C,B,D + C) + 5 \/ ((odd(D) \/ A) + E) * E,res = 45,count = 1] */ data(puzzle2,Data,Vars,Unknown,Ops,Constants,MaxSize,Params) :- % Ops = [+,*,-,/,mod,\/,/\,^,even,odd,if_then_else,==], Ops = [+,*,-,/,mod,even,odd,if_then_else,==,!=,pow2], % Ops = [+,*,-,/,mod,even,odd,if_then_else,==,!=], % get_global_map().put("debug",true), 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'], Constants = 0..10, Unknown = [3,12,4,28,5], MaxSize = 21, Params = new_map([init_size=200 ]).