Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Oasis is a language designed by AdnanAdnan which is specialized in sequences.

Here, we shall use the following relationship kindly provided by Stefano SanfilippoStefano Sanfilippo:

Oasis is a language designed by Adnan which is specialized in sequences.

Here, we shall use the following relationship kindly provided by Stefano Sanfilippo:

Oasis is a language designed by Adnan which is specialized in sequences.

Here, we shall use the following relationship kindly provided by Stefano Sanfilippo:

added 934 characters in body
Source Link
Leaky Nun
  • 50.1k
  • 6
  • 110
  • 284
4 6n>/-*1nxx«*n>÷1

Try it online!Try it online!

4nxx«*n>÷1 6n>/-*1

        1  specify that            stack
        1  a(0)=1

n = 1        push n (input)        n
4 x         pushdouble 4               2n
  6x        pushdouble 6 (separated so that it would not be interpreted as 46     4n
   «       minus 2               4n-2
    *      multiply: second      (4n-2)*a(n-1)
           argument is missing,
           so a(n-1) is used.
     n     push n (input)        (4n-2)*a(n-1) n
    >  >    add 1                 (4n-2)*a(n-1) n+1
       ÷   integer division      (4n-2)*a(n-1)/(n+1)
     divide the two numbers on the top of stack, giving us [4,               = ((4n-2)/(n+1))*a(n-1)
                               = ((4n+4-6)/(n+1)])*a(n-1)
                               = ((4n+4)/(n+1) - 6/(n+1))*a(n-1)
    subtract, giving us [4                        = (4-6/(n+1)])*a(n-1)

Closed-form:

10 bytes

nx!n!n>!*÷

Try it online!

nx!n!n>!*÷

n       *   multiply; thepush secondn argument(input)
 x          double
  !         factorial: stack is missingnow [(2n)!]
   n        push n (input)
    !       factorial: takesstack ais now [(2n)! n-!]
     n      push n (input)
      >     add 1
       !    factorial: stack is now [(2n)! asn! second(n+1)!]
 argument.       *   multiply: stack is now [(2n)! (n!(n+1)!)]
         ÷  divide: stack is now [(2n)!/(n!(n+1)!)]
4 6n>/-*1

Try it online!

4 6n>/-*1

        1  specify that a(0) = 1
4          push 4
  6        push 6 (separated so that it would not be interpreted as 46)
   n       push n (input)
    >      add 1
     /     divide the two numbers on the top of stack, giving us [4, 6/(n+1)]
      -    subtract, giving us [4-6/(n+1)]
       *   multiply; the second argument is missing: takes a(n-1) as second argument.
nxx«*n>÷1

Try it online!

nxx«*n>÷1                        stack
        1  a(0)=1

n          push n (input)        n
 x         double                2n
  x        double                4n
   «       minus 2               4n-2
    *      multiply: second      (4n-2)*a(n-1)
           argument is missing,
           so a(n-1) is used.
     n     push n (input)        (4n-2)*a(n-1) n
      >    add 1                 (4n-2)*a(n-1) n+1
       ÷   integer division      (4n-2)*a(n-1)/(n+1)
                               = ((4n-2)/(n+1))*a(n-1)
                               = ((4n+4-6)/(n+1))*a(n-1)
                               = ((4n+4)/(n+1) - 6/(n+1))*a(n-1)
                               = (4-6/(n+1))*a(n-1)

Closed-form:

10 bytes

nx!n!n>!*÷

Try it online!

nx!n!n>!*÷

n           push n (input)
 x          double
  !         factorial: stack is now [(2n)!]
   n        push n (input)
    !       factorial: stack is now [(2n)! n!]
     n      push n (input)
      >     add 1
       !    factorial: stack is now [(2n)! n! (n+1)!]
        *   multiply: stack is now [(2n)! (n!(n+1)!)]
         ÷  divide: stack is now [(2n)!/(n!(n+1)!)]
Source Link
Leaky Nun
  • 50.1k
  • 6
  • 110
  • 284

Oasis, 9 bytes

4 6n>/-*1

Try it online!

Oasis is a language designed by Adnan which is specialized in sequences.

Here, we shall use the following relationship kindly provided by Stefano Sanfilippo:

Currently, this language can do recursion and closed form.

To specify that a(0)=1 is simple: just add the 1 at the end.

For example, if a sequence begins with a(0)=0 and a(1)=1, just put 10 at the end.

Unfortunately, all sequences must be 0-indexed.

4 6n>/-*1

        1  specify that a(0) = 1
4          push 4
  6        push 6 (separated so that it would not be interpreted as 46)
   n       push n (input)
    >      add 1
     /     divide the two numbers on the top of stack, giving us [4, 6/(n+1)]
      -    subtract, giving us [4-6/(n+1)]
       *   multiply; the second argument is missing: takes a(n-1) as second argument.