Commits

blooper committed 5608792

Answer for problem 9 in Erlang

Comments (0)

Files changed (1)

Erlang/problem0009_1.erl

+-module(problem0009_1).
+-compile(export_all).
+
+ans() -> f(2,1).
+
+f(N, I) ->
+  if
+    2*N*N + 2*N*(N-I) == 1000 ->
+      2*N*(N-I)*(N*N*N*N-(N-I)*(N-I)*(N-I)*(N-I));
+    true ->
+      if
+        N == I -> f(N+1, 1);
+        true -> f(N,I+1)
+      end
+    end.