Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f[depth_, factorial_] := (
- RandomChoice[{
- "n" &,
- ToString[Floor@Sqrt@RandomInteger@10000] &,
- "(-" <> f[depth - 1, factorial] <> ")" &,
- If[factorial, "(" <> f[depth - 1, False] <> "!)",
- f[depth, False]] &,
- "(" <> f[depth - 1, factorial] <> "+" <>
- f[depth - 1, factorial] <> ")" &,
- "(" <> f[depth - 1, factorial] <> "-" <>
- f[depth - 1, factorial] <> ")" &,
- "(" <> f[depth - 1, factorial] <> "*" <>
- f[depth - 1, factorial] <> ")" &,
- "(" <> f[depth - 1, factorial] <> "/" <>
- f[depth - 1, factorial] <> ")" &,
- If[factorial,
- "(" <> f[depth - 1, factorial] <> "^" <>
- f[depth - 1, False] <> ")", f[depth, False]] &,
- If[factorial,
- "Binomial[" <> f[depth - 1, False] <> "," <>
- f[depth - 1, False] <> "]", f[depth, False]] &
- }[[1 ;; If[depth == 0, 2, -1]]]][]
- );
- series = {};
- While[Length@series < 50,
- func = f[4, True];
- values = Table[ToExpression@func, {n, 20}];
- values =
- values[[1 ;;
- LengthWhile[values, IntegerQ@# && # > 0 && # < 10^20 &]]];
- If[Length@values > 1 && values[[1]] != values[[2]] &&
- FreeQ[series, {_, values}],
- series = Union[series, {{func, values}}]]
- ]
- series // TableForm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement