Advertisement
Guest User

Untitled

a guest
Nov 20th, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. f[depth_, factorial_] := (
  2.    RandomChoice[{
  3.        "n" &,
  4.        ToString[Floor@Sqrt@RandomInteger@10000] &,
  5.        "(-" <> f[depth - 1, factorial] <> ")" &,
  6.        If[factorial, "(" <> f[depth - 1, False] <> "!)",
  7.          f[depth, False]] &,
  8.        "(" <> f[depth - 1, factorial] <> "+" <>
  9.          f[depth - 1, factorial] <> ")" &,
  10.        "(" <> f[depth - 1, factorial] <> "-" <>
  11.          f[depth - 1, factorial] <> ")" &,
  12.        "(" <> f[depth - 1, factorial] <> "*" <>
  13.          f[depth - 1, factorial] <> ")" &,
  14.        "(" <> f[depth - 1, factorial] <> "/" <>
  15.          f[depth - 1, factorial] <> ")" &,
  16.        If[factorial,
  17.          "(" <> f[depth - 1, factorial] <> "^" <>
  18.           f[depth - 1, False] <> ")", f[depth, False]] &,
  19.        If[factorial,
  20.          "Binomial[" <> f[depth - 1, False] <> "," <>
  21.           f[depth - 1, False] <> "]", f[depth, False]] &
  22.        }[[1 ;; If[depth == 0, 2, -1]]]][]
  23.    );
  24. series = {};
  25. While[Length@series < 50,
  26.  func = f[4, True];
  27.  values = Table[ToExpression@func, {n, 20}];
  28.  values =
  29.   values[[1 ;;
  30.      LengthWhile[values, IntegerQ@# && # > 0 && # < 10^20 &]]];
  31.  If[Length@values > 1 && values[[1]] != values[[2]] &&
  32.    FreeQ[series, {_, values}],
  33.   series = Union[series, {{func, values}}]]
  34.  ]
  35. series // TableForm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement