text:
Triangular Dependencies
A triangular number is a number that is the sum of n natural numbers from 1 to n. For example 1 + 2 + 3 + 4 = 10 so 10 is a triangular number.
Given a positive integer (0 < n <= 10000) as input (can be taken as an integer, or as a string), return the smallest possible triangular number that can be added to the input to create another triangular number.
For example given input 26, adding 10 results in 36, which is also a triangular number. There are no triangular numbers smaller than 10 that can be added to 26 to create another triangular number, so 10 is the correct result in this case.
0 is a triangular number, therefore if the input is itself a triangular number, the output should be 0
Testcases
Cases are given in the format input -> output (resulting triangular number)
0     -> 0   (0)
4     -> 6   (10)
5     -> 1   (6)
7     -> 3   (10)
8     -> 28  (36)
10    -> 0   (10)
24    -> 21  (45)
25    -> 3   (28)
26    -> 10  (36)
34    -> 21  (55)
10000 -> 153 (10153)

Scoring
This is code-golf so fewest bytes in each language wins!

Isn't it 26 -> 2?

@Okx I made the same mistake, you need to find a triangular number to add to the current one to make another triangular number.

Related. (borderline duplicate)

@MartinEnder That is not a duplicate

Java 8, 58 57 bytes
n->{int i=0,m=0;while(n!=0)n+=n<0?++i:--m;return-~i*i/2;}

Online test suite
Thanks to Dennis for a 1-byte saving.

Now this is Java, golfed! :)

I count 58 bytes, you seem to have included a trailing newline in the byte-count.

Is order of operations guaranteed on the "i*++i" part?  I could see this maybe not working on some JVM implementations.  Nice solution regardless.

@Computronium, order of operations is guaranteed by the Java Language Specification. Java deliberately avoids some of the weaknesses of C.

@Computronium https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html

return-~i*i/2; saves a byte.

Can't you use n->r->{int i=0,m=0;while(n!=0)n+=n<0?++i:--m;r=-~i*i/2;} to save a byte?

@Okx, really? I'm not sure how you'd invoke that in such a way that the caller gets the updated value of r; and while I admit that I haven't followed every one of the dozens of proposals for standard I/O, I'm not aware of one which would allow it.

@PeterTaylor https://codegolf.meta.stackexchange.com/a/4942/26600 you may even be able to save more bytes by using n->{int i=0,m=0;while(n!=0)n+=n<0?++i:--m;n=-~i*i/2;

@Okx Java is pass-by-value for primitive types and pass-by-reference for objects (including arrays). If you want to actually output in the same variable, you have to be in a pass-by-reference context (explicitly said in your link). The only way I see to pass-by-reference that could work is to pass an int[] instead of an int as argument. But that means dealing with arrays later on. This could work: x->{int i=0,m=0,n=x[0];while(n!=0)n+=n<0?++i:--m;x[0]=-~i*i/2;}, but it's 63 bytes.

Java (OpenJDK 8), 83 bytes
n->{int m=0,a=n,b;for(;a-->0;)for(b=0;b<=n;)m=2*n+b*~b++==a*~a?a*a+a:m;return m/2;}

Try it online!
Credits

-3 bytes thanks to ceilingcat

Nice answer (as always..). Hadn't noticed there was already a Java answer when I posted mine.. Mine was initially shorter, but not anymore it seems. :)

Thanks! Yeah, my first answer was really redundant. I fixed it and made it more mathy, though more processor-greedy as well. I'll check yours in a sec!

I still don't understand what is happening here. Why is it working? You are replacing m every time, so what's the point?

@V.Courtois The question asks for the smallest m. So I go from a down to 0. "but you're assigning maybe 100 times the same value a*a+a to m in the b-loop", yep, I don't need to do it 100 times, but I'm gaining bytes by not breaking the b-loop earlier.

I see @OlivierGrégoire. So that's anti-efficient on purpose :D

@V.Courtois exactly!

82 bytes

MATL, 13 12 bytes
1 byte removed using an idea (set intersection) from Emigna's 05AB1E answer
Q:qYstG-X&X<

Try it online!
Explanation
Let t(n) = 1 + 2 + ··· + n denote the n-th triangular number.
The code exploits the fact that, given n, the solution is upper-bounded by t(n-1). To see this, observe that t(n-1) + n equals t(n) and so it is a triangular number.
Consider input 8 as an example.
Q:q   % Input n implicitly. Push [0 1 2 ... n]
      % STACK: [0 1 2 3 4 5 6 7 8]
Ys    % Cumulative sum
      % STACK: [0 1 3 6 10 15 21 28 36]
t     % Duplicate
      % STACK: [0 1 3 6 10 15 21 28 36], [0 1 3 6 10 15 21 28 36]
G-    % Subtract input, element-wise
      % STACK: [0 1 3 6 10 15 21 28 36], [-8 -7 -5 -2  2  7 13 20 28]
X&    % Set intersection
      % STACK: 28
X<    % Minimum of array (in case there are several solutions). Implicit display
      % STACK: 28

Can you remove the leading Q by your argument about boundedness?

@Giuseppe No, that fails for input 8. When the output equals the bound t(n-1), the code obtains it as t(n)-n. So t(n) is necessary. Thanks for the idea anyway!

Mathematica, 46 bytes
Min[Select[(d=Divisors[2#])-2#/d,OddQ]^2-1]/8&

Neim, 12 9 bytes
tSΛt)0

This takes too long to compute (but works given infinite time and memory), so in the link I only generate the first 143 triangular numbers - using £, which is enough to handle an input of 10,000, but not enough to time out.
Warning: this may not work in future versions. If so, substitute £ for 143
Explanation:
t                 Infinite list of triangular numbers
 [ ]             Select the first  v  numbers
 [£ ]                              143
     S           Subtract the input from each element
       Λ  )       Only keep elements that are
        t          triangular
           0     Get the value closest to 0 - prioritising the higher number if tie

Try it!

How are the first 143 triangle numbers enough for any input between 0 and 10000? With the input 9998, the expected result is 3118753, which is way above the 143rd triangle number (which is `10296).

@OlivierGrégoire because This takes too long to compute (but works given infinite time and memory)

Thank you @StepHen but that's not what I said. What I implied is that the sentence "the first 143 triangular numbers [are] enough to handle an input of 10,000" is wrong. I haven't done the maths, but I believe that you should need around 10000 (give or take) triangle numbers to handle the cases up to 10000.

@OlivierGrégoire I stated that it is enough to handle an input of 10,000, but not any number less than it. Feel free to change £ to a higher number, such as 200.

@Okx Okay, I didn't understand it like that when I first read, thank you for taking the time to explain :)

PHP, 45 bytes
for(;!$$t;$t+=++$i)${$argn+$t}=~+$t;echo~$$t;

Try it online!
Is the shorter variant of for(;!$r[$t];$t+=++$i)$r[$argn+$t]=~+$t;echo~$r[$t];
Expanded
for(;!$$t;  # stop if a triangular number exists where input plus triangular number is a triangular number
$t+=++$i) # make the next triangular number
  ${$argn+$t}=~+$t; # build variable $4,$5,$7,$10,... for input 4
echo~$$t; # Output result

PHP, 53 bytes
for(;$d=$t<=>$n+$argn;)~$d?$n+=++$k:$t+=++$i;echo+$n;

Try it online!
Use the new spaceship operator in PHP 7
Expanded
for(;$d=$t<=>$n+$argn;) # stop if triangular number is equal to input plus triangular number
  ~$d
    ?$n+=++$k  # raise additional triangular number
    :$t+=++$i; # raise triangular number sum
echo+$n; # Output and cast variable to integer in case of zero

PHP, 55 bytes
for(;fmod(sqrt(8*($t+$argn)+1),2)!=1;)$t+=++$i;echo+$t;

Try it online!

Java 8, 110 102 100 93 92 bytes
n->{int r=0;for(;t(r)<-t(n+r);r++);return r;}int t(int n){for(int j=0;n>0;n-=++j);return n;}

-2 bytes thanks to @PeterTaylor.
-7 bytes thanks to @JollyJoker.
-1 byte thanks to @ceilingcat.
Explanation:
Try it online.
n->{                  // Method with integer as parameter and return-type
  int r=0;            //  Result-integer (starting at 0)
  for(;t(r)<-t(n+r);  //  Loop as long as neither `r` nor `n+r` is a triangular number
    r++);             //   And increase `r` by 1 after every iteration
  return r;}          //  Return the result of the loop

int t(int n){         // Separate method with integer as parameter and return-type
                      // This method will return 0 if the input is a triangular number
  for(int i=0;n>0;)   //  Loop as long as the input `n` is larger than 0
    n-=++j;           //   Decrease `n` by `j` every iteration, after we've raised `j` by 1
  return n;}          //  Return `n`, which is now either 0 or below 0

Easiest to read of the Java solutions :)

@JollyJoker Maybe that's why it's the longest. ;) Or is it because of my added explanation?

Nah, I was thinking about the code. I probably spent 15 mins figuring out how Peter Taylor's solution works. Yours is clear even without the comments.

Brachylog, 17 15 bytes
⟦{a₀+}ᶠ⊇Ċ-ṅ?∧Ċh

Try it online!
Explanation
⟦                  [0, …, Input]
 {   }ᶠ            Find all…
  a₀+                …Sums of prefixes (i.e. triangular numbers)
       ⊇Ċ          Take an ordered subset of two elements
         -ṅ?       Subtracting those elements results in -(Input)
            ∧Ċh    Output is the first element of that subset

Japt, 24 23 16 15 13 bytes
ò å+
m-N æ@øX

1 byte saved thanks to ETH.
Try it
ò å+\nm-N æ@øX     :Implicit input of integer U
ò                  :Range [0,U]
  å+               :Cumulatively reduce by addition
    \n             :Reassign to U
      m-           :Map and subtract
        N          :  The array of inputs (i.e., the original value of U)
         æ         :Get the first element that return true when
          @        :Passed through the following function as X
           øX      :  Does U contain X

I think you can save a byte with æ!øV. Other than that, looks great :-)

Octave, 38 36 bytes
2 bytes off thanks to @Giuseppe!
@(n)(x=cumsum(0:n))(any(x+n==x'))(1)

Anonymous function that uses almost the same approach as my MATL answer.
Try it online!

Jelly, 8 bytes
0r+\ðf_Ḣ

Try it online!
How it works
0r+\ðf_Ḣ  Main link. Argument: n

0r        Build [0, ..., n].
  +\      Take the cumulative sum, generating A := [T(0), ..., T(n)].
    ð     Begin a dyadic chain with left argument A and right argument n.
      _   Compute A - n, i.e., subtract n from each number in A.
     f    Filter; keep only numbers of A that appear in A - n.
       Ḣ  Head; take the first result.

Python 2, 59 bytes
lambda n:min((r-2*n/r)**2/8for r in range(1,2*n,2)if n%r<1)

Try it online!
This uses the following characterization of the triangular numbers t than can be added to n to get a triangular number:

8*t+1 = (r-2*s)^2 for divisor pairs (r,s) with r*s==n and r odd.

The code takes the minimum of all such triangular numbers.

C (GCC), 58 55 54 52 bytes
i;s;f(n){for(i=s=0;n;)n+=n<0?++i:--s;return-~i*i/2;}

Attempt This Online!
EDIT: -3 bytes by removing !=0
EDIT: -1 byte by moving variable declarations to a for
EDIT: -2 bytes by moving variable declarations outside the function, thanks to ceilingcat
Explanation
i;s;f(n){for(i=s=0;n;)n+=n<0?++i:--s;return-~i*i/2;}
i;s;                                                  // Declare i and s
    f(n){                                          }  // Declare function:
             i=s=0;                                   // * Set i and s to 0
         for(      n;)                                // * While n not 0:
                      n+=n<0?++i:--s;                 // * * Increment i and add to n if n < 0
                                                      //     Otherwise, decrement s and add to n
                                     return-~i*i/2;   // * Return i*(i+1)/2

Created with the help of Luminespire.

I've never seen Luminespire used to explain C code lol

@noodleman It does work though

Mathematica, 62 bytes
(s=Min@Abs[m/.Solve[2#==(n-m)(n+m+1),{n,m},Integers]])(s+1)/2&

I don't know Mathematica, but would Solve[2*#==m(m+1)-n(n+1) be shorter (if it works)?

yes, I just posted my answer and trying to golf it right now

JavaScript (ES7), 46 44 bytes
f=(n,x=r=0)=>(8*(n+x)+1)**.5%1?f(n,x+=++r):x

Try it

o.innerText=(
f=(n,x=r=0)=>(8*(n+x)+1)**.5%1?f(n,x+=++r):x
)(i.value=8);oninput=_=>o.innerText=f(+i.value)
<input id=i type=number>

Would r=x=0 work?

Sadly not, @KritixiLithos.

Python 2, 78 71 70 bytes
Seven bytes saved, thanx to ovs and theespinosa
One more byte saved due to the remark of neil, x+9 is suffisant and checked for all natural numbers 0 <= n <= 10000. It was also verified for x+1 instead of x+9, it works also.
x=input()
I={n*-~n/2for n in range(x+1)}
print min(I&{i-x for i in I})

Try it online!

You can use n*-~n/2 instead of n*(n+1)/2

Would range(x+9) work?

You can use {n*(n+1)/2for n in range(999)} instead of explicit set and also use {} instead of set in the third line

05AB1E, 12 bytes
ÝηOãD€Æ¹QÏ¬¤

Uses the 05AB1E encoding. Try it online!

JavaScript (ES6), 43 42 bytes

f=(n,a=s=0)=>n?f(n+=n>0?--s:++a,a):a*++a/2
<input type=number min=0 value=0 oninput=o.textContent=f(+this.value)>
0

Edit: Saved 1 byte thanks to @PeterTaylor.

Setting a global variable is a hideous abuse of a default parameter. +1. But FWIW you can save a further byte by replacing -++s with --s, as I did in my independently derived but quite similar Java version. (Addendum: you also need to change the test to n>0).

@PeterTaylor Huh, so the n>s check was a red herring all along!

Works not for 8192

@JörgHülsermann If you're referring to the snippet, then your browser's stack size may not be large enough, or you may need a browser with experimental tail call optimisation. Alternatively, if you're using NodeJS for testing, use node --stack_size= to increase its stack size.

05AB1E, 8 bytes
ÝηODI-Ãн

Try it online!
or as a Test suite
Explanation
Ý          # range [0 ... input]
 η         # prefixes
  O        # sum each
   D       # duplicate
    I-     # subtract input from each
      Ã    # keep only the elements in the first list that also exist in the second list
       н   # get the first (smallest)

Python 3, 60 44 bytes
f=lambda n,k=1:(8*n+1)**.5%1and f(n+k,k+1)+k

Thanks to @xnor for a suggestion that saved 16 bytes!
Try it online!
Background
Let n be a non-negative integer. If n is the kth triangular number, we have

which means there will be a natural solution if and only if 1 + 8n is an odd, perfect square. Clearly, checking the parity of 1 + 8n is not required.
How it works
The recursive function n accepts a single, non-negative integer as argument. When called with a single argument, k defaults to 1.
First, (8*n+1)**.5%1 tests if n is a triangular number: if (and only if) it is, (8*n+1)**.5 will yield an integer, so the residue from the division by 1 will yield 0.
If the modulus is 0, the and condition will fail, causing f to return 0. If this happens in the initial call to f, note that this is the correct output since n is already triangular.
If the modulus is positive, the and condition holds and f(n+k,k+1)+k gets executed. This calls f again, incrementing n by k and k by 1, then adds k to the result.
When f(n0, k0) finally returns 0, we back out of the recursion. The first argument in the first call was n, the second one n + 1, the third one n + 1 + 2, until finally n0 = n + 1 + … k0-1. Note that n0 - n is a triangular number.
Likewise, all these integers will be added to the innermost return value (0), so the result of the intial call f(n) is n0 - n, as desired.

If you increment n in recursing as well, you can write n rather than (n+k).

Or better, search triangular numbers directly.

Wow, that's a lot nicer than what I was trying.

C# (.NET Core), 291 281 bytes
class p{static int Main(string[]I){string d="0",s=I[0];int c=1,j,k;for(;;){j=k=0;string[]D=d.Split(' '),S=s.Split(' ');for(;j<D.Length;j++)for(;k<S.Length;k++)if(D[j]==S[k])return int.Parse(D[k]);j=int.Parse(D[0])+c++;d=d.Insert(0,$"{j} ");s=s.Insert(0,$"{j+int.Parse(I[0])} ");}}}

Try it online!
Program that takes a string as input and outputs through Exit Code.
Saved 10 Bytes thanks to Kevin Cruijssen

Hi, welcome to PPCG! You don't need a full program unless the challenge states otherwise. The default is program/function, so a lambda is allowed as well in C#. But if you want to use program, you can golf some things in your current code: class p{static int Main(string[]I){string d="0",s=I[0];int c=1,j,k;for(;;){j=k=0;string[]D=d.Split(' '),S=s.Split(' ');for(;j<D.Length;j++)for(;k<S.Length;k++)if(D[j]==S[k])return int.Parse(D[k]);j=int.Parse(D[0])+c++;d=d.Insert(0,$"{j} ");s=s.Insert(0,$"{j+int.Parse(I[0])} ");}}} (281 bytes)

@KevinCruijssen Thanks for the advice! using for(;;) to make an infinite loop is a nice bump, and I'll make sure to think more carefully about whether using var is actually more efficient than using an explicit type but combining the declarations, and I guess be more diligent in removing unnecessary brackets. As for the program vs. function, I started with a lambda but couldn't get it to run in TIO. I know a TIO link isn't actually necessary, but it's something I like to see in others' answers so I wanted at least something similar in my own.

I'm also not very good in C# lambdas tbh, I usually codegolf in Java. But I think this should be correct. (252 bytes). Also, in case you haven't seen it yet: Tips for code-golfing in C# and Tips for golfing in  might be interesting to read through. Again welcome, and +1 from me. Nice first answer. Enjoy your stay. :)

Husk, 10 bytes
`ḟ∫ΘNo£∫N+

Try it online!

Dyalog APL, 19 bytes
6 bytes saved thanks to @KritixiLithos
{⊃o/⍨o∊⍨⍵+o←0,+\⍳⍵}

Try it online!
How?
o←0,+\⍳⍵ - assign o the first ⍵ triangular numbers
o/⍨ - filter o by
o∊⍨⍵+o - triangular numbers that summed with ⍵ produce triangulars
⊃ - and take the first

+\⍳⍵ should work instead of what you are using to generate the triangular numbers.

I think ⊃ works instead of ⌊/

Pari/GP, 54 bytes
n->vecmin([y^2-1|y<-[2*n/d-d|d<-divisors(2*n)],y%2])/8

Try it online!

R, 46 44 43 41 bytes
function(x,y=cumsum(0:x))y[(x+y)%in%y][1]

Try it online!
An anonymous function with one mandatory argument, x; computes first x+1 triangular numbers as an optional argument to golf out a few curly braces. I used choose before I saw Luis Mendo's Octave answer.
I shaved off a few bytes of Luis Mendo's answer but forgot to use the same idea in my answer.

Add++, 68 bytes
L,RBFEREsECAAx$pBcB_B]VARBFEREsB]GEi$pGBcB*A8*1+.5^1%!!@A!@*b]EZBF#@

Try it online!, or see the test suite!
Even Java is beating me. I really need to add some set commands to Add++
How it works
L,    - Create a lambda function
      - Example argument:  8
  R   - Range;     STACK = [[1 2 3 4 5 6 7 8]]
  BF  - Flatten;   STACK = [1 2 3 4 5 6 7 8]
  ER  - Range;     STACK = [[1] [1 2] ... [1 2 3 4 5 6 7 8]
  Es  - Sum;       STACK = [1 3 6 10 15 21 28 36]
  EC  - Collect;   STACK = [[1 3 6 10 15 21 28 36]]
  A   - Argument;  STACK = [[1 3 6 10 15 21 28 36] 8]
  A   - Argument;  STACK = [[1 3 6 10 15 21 28 36] 8 8]
  x   - Repeat;    STACK = [[1 3 6 10 15 21 28 36] 8 [8 8 8 8 8 8 8 8]]
  $p  - Remove;    STACK = [[1 3 6 10 15 21 28 36] [8 8 8 8 8 8 8 8]]
  Bc  - Zip;       STACK = [[1 8] [3 8] [6 8] [10 8] [15 8] [21 8] [28 8] [36 8]]
  B_  - Deltas;    STACK = [-7 -5 -2 2 7 13 20 28]
  B]  - Wrap;      STACK = [[-7 -5 -2 2 7 13 20 28]]
  V   - Save;      STACK = []
  A   - Argument;  STACK = [8]
  R   - Range;     STACK = [[1 2 3 4 5 6 7 8]]
  BF  - Flatten;   STACK = [1 2 3 4 5 6 7 8]
  ER  - Range;     STACK = [[1] [1 2] ... [1 2 3 4 5 6 7 8]]
  Es  - Sum;       STACK = [1 3 6 10 15 21 28 36]
  B]  - Wrap;      STACK = [[1 3 6 10 15 21 28 36]]
  G   - Retrieve;  STACK = [[1 3 6 10 15 21 28 36] [-7 -5 -2 2 7 13 20 28]]
  Ei  - Contains;  STACK = [[1 3 6 10 15 21 28 36] [0 0 0 0 0 0 0 1]]
  $p  - Remove;    STACK = [[0 0 0 0 0 0 0 1]]
  G   - Retrieve;  STACK = [[0 0 0 0 0 0 0 1] [-7 -5 -2 2 7 13 20 28]]
  Bc  - Zip;       STACK = [[0 -7] [0 -5] [0 -2] [0 2] [0 7] [0 13] [0 20] [1 28]]
  B*  - Products;  STACK = [0 0 0 0 0 0 0 28]
  A   - Argument;  STACK = [0 0 0 0 0 0 0 28 8]
  8*  - Times 8;   STACK = [0 0 0 0 0 0 0 28 64]
  1+  - Increment; STACK = [0 0 0 0 0 0 0 28 65]
  .5^ - Root;      STACK = [0 0 0 0 0 0 0 28 8.1]
  1%  - Frac part; STACK = [0 0 0 0 0 0 0 28 0.1]
  !!  - To bool;   STACK = [0 0 0 0 0 0 0 28 1]
  @   - Reverse;   STACK = [1 28 0 0 0 0 0 0 0]
  A   - Argument;  STACK = [1 28 0 0 0 0 0 0 0 8]
  !   - Not;       STACK = [1 28 0 0 0 0 0 0 0 0]
  @   - Reverse;   STACK = [0 0 0 0 0 0 0 0 28 1]
  *   - Multiply;  STACK = [0 0 0 0 0 0 0 0 28]
  b]  - Wrap;      STACK = [0 0 0 0 0 0 0 0 [28]]
  EZ  - Unzero;    STACK = [[28]]
  BF  - Flatten;   STACK = [28]
  #   - Sort;      STACK = [28]
  @   - Reverse;   STACK = [28]

Haskell, 56 bytes
f x|e<-(`elem`scanl1(+)[0..x])=[n|n<-[0..],e n,e$x+n]!!0

Try it online!

Python 2, 83 81 bytes

@Felipe Nardi Batista saved 2 bytes.

lambda n:min(x for x in i(n)if n+x in i(n))
i=lambda n:[i*-~i/2for i in range(n)]

Try it online!

Jelly, 18 bytes
0rRS$€ċ
0ð,+Ç€Ạð1#

Try it online!

APL (Dyalog Classic), 16 14 bytes
(⊃0∘,∩⊢-≢)+\∘⍳

Try it online!

Clojure, 74 bytes
#(nth(for[t[(reductions +(range))]i t :when((set(take 1e5 t))(+ i %))]i)0)
#(nth(for[R[reductions]i(R + %(range)):when((set(R - i(range 1e5)))0)]i)0)

Pick your favourite :) Loops might be shorter...

Python 2, 82 bytes
f=lambda n,R=[1]:n-sum(R)and f(n,[R+[R[-1]+1],R[1:]][sum(R)>n])or sum(range(R[0]))

Try it online
This was created by modifying this answer from the related question.

works not for 8192

It doesn't work for that on the related question either, because of the recursion depth. I'm not sure what the consensus is on that.

Some other answers have the same problem. I give only the info

Retina, 70 bytes
.+
$*
1+
$&;$&;
{`^(1+);(?=(\b1|1\2)+;)\1(1*);1*
$3
}`;(1*)$
1$1;1$1
1

Try it online! Link includes test suite. Explanation: The algorithm works with three numbers, the input number, the sum of the input number and the current triangular number, and the index of the current triangular number. If the sum is triangular (using @MartinEnder's excellent algorithm) then the whole thing is replaced by the difference of the sum and the original number, thus achieving the desired result. Otherwise, the index is incremented and added to the sum, until the sum becomes triangular. Note that if the input number is zero then all of this is simply ignored as the result is zero anyway.

Swift 3.0,97 bytes
let n=4
var o=0,s=0.0;for i in 0...n{o=i*(i+1)/2;s=sqrt(Double(8*(n+o)+1))
if floor(s)==s{break}}

To see output use print(o)
Try it online!

Ruby, 44 bytes
->n{*r=a=b=0;r<{var i,m,N=0L;N=n;while(N!=0){if(N<0){i+=1;N+=i}else{m+=1L;N-=m}};i*(i+1)/2}

Attempt This Online!

APL(NARS), 51 chars
r←B w;n;k
n←¯1
n+←1⋄r←2÷⍨n×n+1⋄→2×⍳k≠2*⍨⌊√k←1+8×w+r

9+4+36+2=51
test:
      {'B(',(⍕⍵),')=',⍕B⍵}¨0 4 5 7 8 10 24 25 26 34 10000
 B(0)=0 B(4)=6 B(5)=1 B(7)=3 B(8)=28 B(10)=0 B(24)=21 B(25)=3 B(26)=10 B(34)=21 B(10000)=153


text:
How much Mana do I need?
Dungeon Master was one of the first ever real-time role-playing games, originally released in 1987 on the Atari ST. Among other exciting things for the time, it offered a rather sophisticated spell system based on runes.
Your task today is to write a program or function that evaluates the number of Mana points required to cast a given spell in Dungeon Master.

The 'spell cast' system is the top right cyan box in the above picture.
Spells, runes and Mana
Dungeon Master spells are composed of 2 to 4 runes, picked among the following categories, in this exact order:

Power (mandatory)
Elemental Influence (mandatory)
Form (optional)
Class / Alignment (optional)

It means that valid spells are either:

Power + Elemental Influence
Power + Elemental Influence + Form
Power + Elemental Influence + Form + Class / Alignment

Each category contains 6 runes, and each rune has an associated base Mana cost:
=============================================================================
| Power               | Rune      |   Lo |   Um |   On |   Ee |  Pal |  Mon |
|                     +-----------+------+------+------+------+------+------+
|                     | Base cost |    1 |    2 |    3 |    4 |    5 |    6 |
=============================================================================
| Elemental Influence | Rune      |   Ya |   Vi |   Oh |  Ful |  Des |   Zo |
|                     +-----------+------+------+------+------+------+------+
|                     | Base cost |    2 |    3 |    4 |    5 |    6 |    7 |
=============================================================================
| Form                | Rune      |  Ven |   Ew | Kath |   Ir |  Bro |  Gor |
|                     +-----------+------+------+------+------+------+------+
|                     | Base cost |    4 |    5 |    6 |    7 |    7 |    9 |
=============================================================================
| Class / Alignment   | Rune      |   Ku |  Ros | Dain | Neta |   Ra |  Sar |
|                     +-----------+------+------+------+------+------+------+
|                     | Base cost |    2 |    2 |    3 |    4 |    6 |    7 |
=============================================================================

Evaluating the Mana cost
The Mana cost of the spell is the sum of the Mana cost of all runes:

The cost of the Power rune always equals its base cost (from 1 to 6).
For the other runes, the following formula applies:

where power is the base cost of the Power rune.

Examples
Spell: Lo Ful
Cost : 1 + floor((1 + 1) * 5 / 2) = 1 + 5 = 6

Spell: Um Ful
Cost : 2 + floor((2 + 1) * 5 / 2) = 2 + 7 = 9

Spell: Pal Vi Bro
Cost : 5 + floor((5 + 1) * 3 / 2) + floor((5 + 1) * 7 / 2) = 5 + 9 + 21 = 35

Clarifications and rules

Your input will consist of 2 to 4 strings designating the runes of the spell. You can take them in any reasonable format, such as 4 distinct parameters,  an array of strings (e.g. ['Lo', 'Ful']), or just one string with a single-character separator of your choice (e.g. 'Lo Ful'). Please specify the selected input format in your answer.
The runes are guaranteed to be valid.
The order of the categories must be respected. Unused categories may be either missing or replaced with some falsy value.
You can accept the runes in any of these formats: 1. A capital letter followed by lower case ('Ful') 2. All lower case ('ful') 3. All upper case ('FUL'). But you can't mix different formats.
Quite obviously, we do not care to know whether the spell actually has some effect in the game (for the curious, useful spells are listed here.)
This is code-golf, so the shortest code in bytes wins.
And remember: Lord Chaos is watching you!

Test cases
Spell          | Output
---------------+-------
Lo Ful         | 6
Um Ful         | 9
On Ya          | 7
Lo Zo Ven      | 12
Pal Vi Bro     | 35
Ee Ya Bro Ros  | 31
On Ful Bro Ku  | 31
Lo Zo Kath Ra  | 20
On Oh Ew Sar   | 35
Ee Oh Gor Dain | 43
Mon Zo Ir Neta | 68
Mon Des Ir Sar | 75

Tangential - but for people that like this system, The Magical Land of Wozz is a Japanese SNES game (English translation available) that implements nearly the same system - where any string of letters becomes a spell. https://www.google.co.jp/webhp?ie=UTF-8#q=magical+land+of+wozz

I have a vague memory of watching someone play Dungeon Master (I don't think it was on the ST). They had equipped one of their fighters with a magic necklace, and every so often they would check whether it had recharged and if so cast another rune of what I think was a light producing spell of some sort, so that the fighter was able to cast this spell every ten minutes or so, and eventually gained a level in wizardry.

@Neil This necklace was probably either the Moonstone (+3 Mana) or the Pendant Feral (+1 Wizard Skill). All items are listed here.

this script should output all possible input combinations

SOGL V0.12, 110 78 bytes
θKKι"LUOEPM”;W:A≤{B"⁶Μ↓§QΕņj“L─"¶Ζq«╝γDyΜ2¶S◄Μ$‘č¹I6nēwι{_Cb:ƧRA=┌*ΚKι=?aIc*»+

Try it Here!
Could probably golf a byte or two from redoing everything
Explanation:
θ            split on spaces
 K           pop the 1st item
  K          pop from the string the 1st character
   ι         remove the original string from stack
    "”;W     get the chars index in "LUOEPM"
        :A   save a copy to variable A
          ≤  put the power (used as the mana) on the bottom of the stack (with the thing above being the input array)

{            for the leftover items in the input do
 B             save the current name on B
  "..“         push 456779223467234567
      L─       base-10 decode it (yes, silly, but it converts it to an array of digits)
        ".‘    push "VEKIBGKRDN-SYVOFDZ"

      č        chop to characters
       ¹       create an array of those two
        I      rotate clockwise
         6n    group to an array with sub-arrays of length 6 (so each array in the array contains 3 items, corresponding to the categories, each with 6 arrays with the runes 1st letter (or "-" in the case of Ra) and base cost)
           ē   push variable e (default = user input number, which errors and defaults to 0) and after that increase it (aka `e++`)
            w  get that item in the array (the array is 1-indexed and the variable is not, so the array was created shifted (which somehow saves 0.9 ≈ 1 byte in the compression))

 ι             remove the original array
  {            for each in that (current category) array
   _             dump all contents on stack (so pushing the runes name and then base cost)
    C            save pop (base cost) on variable B
     b:          duplicate the name
       ƧRA=      push if pop = "RA"
           ┌*    get that many (so 0 or 1) dashes
             Κ   prepend the "" or "-" to the name
              K  pop the 1st letter of the name
               ι remove the modified name, leaving the 1st letter on the stack

         =?      if top 2 are equal (one of the dumped items and the 1st letter of the current inputs)
           a       push variable A (the power)
            I      increase it
             c     push variable C (the current base cost)
              *    multiply
               »   floor-divide by 2
                +  add that to the power

that's what make it even more interesting

Can you add an explanation?

@CalculatorFeline Kinda forgot about this answer. Will probably golf & then add an explanation

Python 2, 135 119 115 bytes
b=[int('27169735 2  4567 435262'[int(x,36)%141%83%50%23])for x in input()]
print b[0]+sum(a*-~b[0]/2for a in b[1:])

Try it online!
Input is list of strings from stdin

Outgolfed... >.<

I have copied your TIO input method to my answer as well, hope you don't mind.

@Mr.Xcoder I have now included all test cases. You can copy them if you want to

Oo, nicely done on the indexing - mind if I borrow it for my JS solution?

05AB1E, 83 82 bytes
.•Y<εΔ•¹нk©.•M₄Pç•²нkÌ.•Jrû •³нkD(i\ë4 3‡4+}.•A1Δ#•I4èkD(i\ë3LJ012‡Ì})ćsv®>y*;(î(+

Try it online!
-1 thanks to Emigna.
SOOOOOOO ungolfed :(
Explanation:
.•Y<εΔ•¹нk©.•M₄Pç•²нkÌ.•Jrû •³нkD(i\ë4 3‡4+}.•A1Δ#•I4èkD(i\ë3LJ012‡Ì})ćsv®>y*;(î(+ Accepts four runes as separate lines, lowercase. Use Ø for missing runes.
.•Y<εΔ•¹нk©                                                                        Index first letter of first rune into "aluoepm" ("a" makes 1-indexed)
           .•M₄Pç•²нkÌ                                                             Index first letter of second rune into "yvofdz", 2-indexed.
                      .•Jrû •³нkD(i\ë4 3‡4+}                                       Index first letter of third rune into "vekibg", 0-indexed, if it's not there pop, else, if index is 4 replace with 3, else keep as-is, then increment by 4.
                                            .•A1Δ#•I4èkD(i\ë3LJ012‡Ì}              Index fourth letter (modular wrapping) of fourth rune into "kodnra", if it's not there pop, else, if index is one of 1, 2 or 3, replace with 0, 1 or 2 respectively, else keep as-is, then increment by 2.
                                                                     )ćs           Wrap all numbers into a list, keeping the power rune behind.
                                                                        v          For each
                                                                         ®>y*;(î(   Apply the formula
                                                                                +  Add to total sum

One small golf would be that if you index into .•Y<εΔ• at the beginning, you don't need to increment the index.

@Emigna Ooh didn't have time to try that yet...

JavaScript (ES6), 157 156 116 112 100 99 97 bytes
Takes input as an array of strings.
a=>a.map(c=>t+=(v=+`27169735020045670435262`[parseInt(c,36)%141%83%50%23],+a?a*v+v>>1:a=v),t=0)|t

Saved a massive 44 bytes by borrowing the indexing trick from ovs' Python solution - if you're upvoting this answer, please upvote that one too.
Saved 13 bytes thanks to Arnauld pointing out what should have been an obvious opportunity to use a ternary.

Try it Online!

Explanation
Hoo, boy, this is gonna be fun - my explanations to trivial solutions suck at the best of times! Let's give it a go ...
a=>

An anonymous function taking the array as an argument via parameter a.
a.reduce((t,c)=>,0)

Reduce the elements in the array by passing each through a function; the t parameter is the running total, the c parameter is the current string and 0 is the initial value of t.
parseInt(c,36)

Convert the current element from a base 36 string to a decimal integer.
%141%83%50%23

Perform a few modulo operations on it.
+`27169735 2  4567 435262`[]

Grab the character from the string at that index and convert it to a number.
v=

Assign that number to variable v.
+a?

Check if variable a is a number. For the first element a will be the array of strings, trying to convert that to a number will return NaN, which is falsey. On each subsequent pass, a will be a positive integer, which is truthy.
a*v+v>>1

If a is a number then we multiply it by the value of v, add the value of v and shift the bits of the result 1 bit to the right, which gives the same result as dividing by 2 and flooring.
:a=v

If a is not a number the we assign the value of v to it, which will also give us a 0 to add to our total on the first pass.
t+

Finally, we add the result from the ternary above to our running total.

Original, 156 bytes
a=>a.reduce((t,c)=>t+(p+1)*g(c)/2|0,p=(g=e=>+`123456234567456779223467`["LoUmOnEePaMoYaViOhFuDeZoVeEwKaIrBrGoKuRoDaNeRaSa".search(e[0]+e[1])/2])(a.shift()))

You can save one more byte by reusing a: a=>a.reduce((t,c)=>t+(v=+'27169735020045670435262'[parseInt(c,36)%141%83%50%23],+a?a*v+v>>1:a=v),0) (EDIT: removed an irrelevant comment about integers passed in the input -- it seems like I didn't understand my own challenge very well ^^)

Neat trick, thanks, @Arnauld. Trying to come up with a calculation that would give me the number we're indexing in less bytes at the moment but not having much luck.

JavaScript, 212 210 207 206 bytes
Straight-forward searching algorithm, the search strings are just contributing to the total bytes.
Code
s=>eval('p=q=+(e=s.map(r=>"1 2 3 4 5  6  2 3 4 5  6  7 4  5 6   7 7  9  2 2  3   4   6 7"["LoUmOnEePalMonYaViOhFulDesZoVenEwKathIrBroGorKuRosDainNetaRaSar".search(r)])).shift();e.map(c=>p+=((q+1)*c)>>1);p')

Input Format
String array, each item is a first-letter-capitalized string. Example: ["Mon", "Zo", "Ir", "Neta"]
Explanation
e=s.map(r=>"1 2 3 4 5  6  2 3 4 5  6  7 4  5 6   7 7  9  2 2  3   4   6 7"["LoUmOnEePalMonYaViOhFulDesZoVenEwKathIrBroGorKuRosDainNetaRaSar".search(r)])

This queries for the basic costs.
p=q=+(/*blah*/).shift()

Initializes 2 variables with the first item from the array result above, and remove that item. Must be cast to number first, otherwise it will be considered as string concatenation in the next part.
e.map(c=>p+=((q+1)*c)>>1);

Adds the costs of the non-power runes to the base power. Shifting is used instead of floor(blah)/2.
eval(/*blah*/;p)

Evaluate the last result. (Credit: Step Hen)
Test Cases
Lo Ful | 6
Um Ful | 9
On Ya | 7
Lo Zo Ven | 12
Pal Vi Bro | 35
Ee Ya Bro Ros | 31
On Ful Bro Ku | 31
Lo Zo Kath Ra | 20
On Oh Ew Sar | 35
Ee Oh Gor Dain | 43
Mon Zo Ir Neta | 68
Mon Des Ir Sar | 75

Edit 1: 212 > 210 - Removed a pair of braces
Edit 2: 210 > 207 - Thanks Step Hen for reminder on JS rules and some hint on using eval() function. Since AS3 forbids the use of eval() I haven't use that for long time
Edit 3: 207 > 206 - Thanks Shaggy for the idea replacing indexOf() with search()

Unless you call g inside of g, we allow JS answers to remove the g=. Also, you can save a couple bytes by switching it to an eval and removing the return: Fiddle

@StepHen Thanks for the eval() idea and the JS rules, since AS3 forbade the eval() I thought I can't use that anymore

Well, it still works, and we define the language by the implementation :P

search will save you a bytes over indexOf.

@Shaggy It worked, thanks for the search idea ;)

No problem. You might be able to get a few more ideas from my solution to save some more bytes.

@Shaggy First time to see reduce(), wondering what does this function do :P

See here for info on reduce.

Only now noticing this is your first solution here - very nicely done :)

Well, actually this is my second one though. I posted the first without registering, so it didn't leave record for that.

In case you can't see edit histories yet, here's what I was hinting you lift from the original version of my solution to get you down to 164 bytes: s=>eval('p=q=+(e=s.map(r=>"123456234567456779223467"["LoUmOnEePaMoYaViOhFuDeZoVeEwKaIrBrGoKuRoDaNeRaSa".search(r[0]+r[1])/2])).shift();e.map(c=>p+=((q+1)*c)>>1);p')

@Shaggy I saw that before you edited it away, though I didn't think of chopping the indices at that time

Python 2, 320 318 314 311 307 bytes
Input Format - List of Strings. Full program:
i=input()
t=[x.split()for x in"Lo Um On Ee Pal Mon|Ya Vi Oh Ful Des Zo|Ven Ew Kath Ir Bro Gor|Ku Ros Dain Neta Ra Sar".split('|')]
c=t[0].index(i[0])+1;r=c+1;s=c+r*(t[1].index(i[1])+2)/2
if len(i)>2:s+=r*(t[2].index(i[2])+4-(i[2]=='Bro'))/2
if len(i)>3:s+=r*(t[3].index(i[3])+1+(i[3]in'KuRaSar'))/2
print(s)

Try it online!

I kind of gave up golfing this, so anyone who has golfing ideas is welcome to edit in themselves.

Excel, 339 bytes
Inputs entered in A1 through D1.  Formula in any other cell.
=CHOOSE(MOD(CODE(A1),12),2,,,1,6,,3,5,4)+INT((CHOOSE(MOD(CODE(A1),12),2,,,1,6,,3,5,4)+1)*CHOOSE(MOD(CODE(B1),12),,3,,,2,7,4,6,,5)/2)+INT((CHOOSE(MOD(CODE(A1),12),2,,,1,6,,3,5,4)+1)*CHOOSE(MOD(CODE(C1),12),7,4,6,,,7,,,5,,9)/2)+INT((CHOOSE(MOD(CODE(A1),12),2,,,1,6,,3,5,4)+1)*CHOOSE(MOD(CODE(SUBSTITUTE(D1,"Ra","E")),11),4,3,6,,2,7,,,2,0)/2)

Alternatively, importing as CSV:
Excel & CSV, 228 bytes
,,,
=CHOOSE(MOD(CODE(A1),12),2,,,1,6,,3,5,4)+1
=A2-1+INT(A2*CHOOSE(MOD(CODE(B1),12),,3,,,2,7,4,6,,5)/2)+INT(A2*CHOOSE(MOD(CODE(C1),12),7,4,6,,,7,,,5,,9)/2)+INT(A2*CHOOSE(MOD(CODE(SUBSTITUTE(D1,"Ra","E")),11),4,3,6,,2,7,,,2,0)/2)
Input entered in first row, SPACE for nulls.  Result displayed in A3.

Haskell, 159 156 148 133 130 127 bytes
k(p:y)=sum$floor<$>c p:map(\x->c x*(c p+1)/2)y
c s=read["3764529516342767"!!(foldl(\c n->c*94+fromEnum n-9)0s%7086%17)]
(%)=mod

Try it online!

SCALA, 1106 chars, 1106 bytes
This is quite long, probably optimizable, but it was fun to do :)
Input format : space-separated runes in a string. If there is only 2 inputs (like "Lo Ful") my code completes it with while(k.length<4)k:+="" (so I can save 24 bytes by changing the parameters, if I require it to be "A B C D").
def n(i:Int,p:String):Int={Math.floor(i*((""+p(0)).toInt+1)/2).toInt}
def m(s:String):Int={var k=s.split(' ')

while(k.length<4)k:+=""
k match{case Array(p,i,f,a)=>{p match{case "Lo"=>1+m(1+"/ "+i+" "+f+" "+a)
case "Um"=>2+m(2+"/ "+i+" "+f+" "+a)
case "On"=>3+m(3+"/ "+i+" "+f+" "+a)
case "Ee"=>4+m(4+"/ "+i+" "+f+" "+a)
case "Pal"=>5+m(5+"/ "+i+" "+f+" "+a)
case "Mon"=>6+m(6+"/ "+i+" "+f+" "+a)
case _ if p.contains("/")=>i match{case "Ya"=>n(2,p)+m(p+" / "+f+" "+a)
case "Vi"=>n(3,p)+m(p+" / "+f+" "+a)
case "Oh"=>n(4,p)+m(p+" / "+f+" "+a)
case "Ful"=>n(5,p)+m(p+" / "+f+" "+a)
case "Des"=>n(6,p)+m(p+" / "+f+" "+a)
case "Zo"=>n(7,p)+m(p+" / "+f+" "+a)
case _ if p.contains("/")=>f match{case "Ven"=>n(4,p)+m(p+" / "+"/ "+a)
case "Ew"=>n(5,p)+m(p+" / "+"/ "+a)
case "Kath"=>n(6,p)+m(p+" / "+"/ "+a)
case "Ir"=>n(7,p)+m(p+" / "+"/ "+a)
case "Bro"=>n(7,p)+m(p+" / "+"/ "+a)
case "Gor"=>n(9,p)+m(p+" / "+"/ "+a)
case _ if p.contains("/")=>a match{case "Ku"=>n(2,p)
case "Ros"=>n(2,p)
case "Dain"=>n(3,p)
case "Neta"=>n(4,p)
case "Ra"=>n(6,p)
case "Sar"=>n(7,p)
case _=>0}
case _=>0}
case _=>0}
case _=>0}}}}

Thanks for this superb challenge. Try it online!

@Arnauld I just noticed something about my code : it doesn't really check if the thing exists! I mean, if I input "Lo Whoo Gor" it outputs 5! Is it okay? Or should I fix this?

That's fine because the "the runes are guaranteed to be valid" (2nd rule).

Oh true :) I did it without thinking so I forgot this rule. Thanks again.

Shakespeare Programming Language, 4420 bytes
,.Ajax,.Ford,.Page,.Puck,.Romeo,.Act I:.Scene I:.[Enter Romeo and Page]Page:You big big big big big big cat.[Exit Romeo][Enter Ajax]Page:Open thy mind!Ajax:Open thy mind!Open thy mind!You is the sum of Romeo and the sum of a big big cat and a cat.Am I as big as you?If not,let us return to Scene V.Page:You is the sum of a big big cat and a cat.Let us return to Act V.Scene V:.Ajax:You is the sum of you and the sum of a big big big cat and a pig.Am I as big as you?If not,let us return to Scene X.Page:You big cat.Let us return to Act V.Scene X:.Ajax:You is the sum of you and the sum of a big cat and a cat.Am I as big as you?If not,let us return to Scene L.Page:You big big cat.Let us return to Act V.Scene L:.Ajax:You is the sum of you and the sum of a big big cat and a big cat.Am I as big as you?If not,let us return to Scene C.Page:You is the sum of a big cat and a cat.Let us return to Act V.Scene C:.Ajax:Am I as big as the sum of you and a big big big pig?Page:You is the sum of a big big cat and a big cat.If so,you is the sum of you and a cat.Ajax:Open thy mind!Act V:.Scene I:.[Exit Ajax][Enter Ford]Page:Open thy mind!Ford:Open thy mind!Open thy mind!You is the sum of Romeo and the sum of a big big big big cat and a pig.Am I as big as you?If not,let us return to Scene V.Page:You big big cat.Let us return to Act X.Scene V:.Ford:You is the sum of you and the sum of a big big big cat and a pig.Am I as big as you?If not,let us return to Scene X.Page:You is the sum of a big cat and a cat.Let us return to Act X.Scene X:.Ford:You is the sum of you and a big big cat.Am I as big as you?If not,let us return to Scene L.Page:You is the sum of a big big big cat and a pig.Let us return to Act X.Scene L:.Ford:Am I as big as the sum of you and a pig?If not,let us return to Scene C.Page:You big cat.Let us return to Act X.Scene C:.Ford:Am I as big as the sum of Romeo and a big big cat?Page:You is the sum of a big big cat and a cat.If so,you is the sum of you and a cat.Ford:Open thy mind!Act X:.Scene I:.[Exit Page][Enter Puck]Ford:You is the sum of the sum of Ajax and a pig and the quotient between the product of Ajax and I and a big cat.Puck:Open thy mind!Is you as big as a pig?If so,let us return to Act D.[Exit Puck][Enter Page]Ford:Open thy mind!Open thy mind!You is the sum of Romeo and the sum of a big big cat and a cat.Am I as big as you?If not,let us return to Scene V.Page:You is the sum of a big big cat and a cat.Let us return to Act L.Scene V:.Ford:Am I as big as the sum of you and a big big cat?If not,let us return to Scene X.Page:You is the sum of a big big big cat and a pig.Let us return to Act L.Scene X:.Ford:Open thy mind!Am I as big as the sum of Romeo and a big cat?If not,let us return to Scene L.Page:You is the sum of a big big big cat and a pig.Let us return to Act L.Scene L:.Ford:You is the sum of Romeo and the sum of a big big big cat and a pig.Am I as big as you?If not,let us return to Scene C.Page:You is the sum of a big big big cat and a cat.Let us return to Act L.Scene C:.Ford:Am I as big as the sum of you and a big big cat?If so,let us return to Scene D.Page:You big big cat.Let us return to Act L.Scene D:.Page:Open thy mind!You is the sum of a big big cat and a big cat.Act L:.Scene I:.[Exit Page][Enter Puck]Ford:You is the sum of you and the quotient between the product of Ajax and I and a big cat.Puck:Open thy mind!Is you as big as a pig?If so,let us return to Act D.[Exit Puck][Enter Page]Ford:You is the sum of Romeo and a big big cat.Am I as big as you?If not,let us return to Scene V.Page:You is the sum of a big cat and a cat.Let us return to Act C.Scene V:.Ford:You is the sum of you and the sum of a big big big cat and a pig.Am I as big as you?If not,let us return to Scene X.Page:You big cat.Let us return to Act C.Scene X:.Ford:Am I as big as the sum of you and the sum of a big cat and a cat?If not,let us return to Scene L.Page:You big big cat.Let us return to Act C.Scene L:.Ford:Am I as big as the sum of you and a big big big cat?If not,let us return to Scene C.Page:You is the sum of a big big big cat and a pig.Let us return to Act C.Scene C:.Page:Open thy mind!Is you as big as the sum of Romeo and a cat?You big cat.If so,you is the sum of you and a big big cat.Act C:.Scene I:.[Exit Page][Enter Puck]Ford:You is the sum of you and the quotient between the product of Ajax and I and a big cat.Act D:.Scene I:.Ford:Open thy heart![Exeunt]

Takes the input as an uppercase string.
Explanation coming soon... For now, Fun fact: Microsoft is a negative noun in SPL. All other accepted words appeared in the works of Shakespeare.
Try it online!

Java (OpenJDK 8), 252 bytes
r->{int c[][]={{2,3,4,5,6,7},{4,5,6,7,7,9},{2,2,3,4,6,7}},l=r.length,p="LUOEPM".indexOf(r[0].charAt(0))+1,a=p,i=0;String[]s={"YVOFDZ","VEKIBG","KRDNXS"};for(;i<l-1;)a+=(p+1)*c[i][s[i++].indexOf((l>3?r[i].replace("Ra","X"):r[i]).charAt(0))]/2;return a;}

Try it online!
The runes are input as a String[] (array of String), in the first case form (first letter is an uppercase, rest is lowercase).
It's the standard "find the n-th letter" method, with the twist that both Ros and Ra exist in the 4th segment. I treated that with an inline and explicit replacement of Ra to X.

@ceilingcat The a+=(p+1) is actually a+= (    (p+1)*c[i][...]    ). So no, I can't do what you suggest, sorry

Retina, 124 123 bytes
Gor
9
[ZIBS]\w+
7
Mon|Des|Kath|Ra
6
..l|Ew
5
Ee|Oh|Ven|Neta
4
[OVD]\w+
3
[UYKR]\w+
2
Lo
1
\d
$*
(?<=^(1+) .*1)
$1
\G1
11
11

Try it online! Link includes test cases. Takes space-separated runes. Explanation: The initial stages simply convert each rune to a digit, which is then converted to unary. The numbers after the first are multiplied by one more than the first number, following which the first number is doubled. The final stage integer divides all the result by 2 and takes the sum.

C, 222
Thanks to @ceilingcat for some very nice pieces of golfing - now even shorter
i;b(r,s)char**r;{for(i=17;i--&&"& ; $ # 4 %        ; B * 6 $ 8          6 5 - >3  +  A@( .   6 5    "[s*17+i]-3-(*r[s]^r[s][1]););return~i?i/2+1:0;}main(n,r)int**r;{n=b(++r,0);printf("%d\n",n-(b(r,1)+b(r,2)+b(r,3))*~n/2);}

Try it online!
A more ungolfed version of my original answer:
#include<stdio.h>
char*a="& ; $ # 4 %      "
       "  ; B * 6 $ 8    "
       "      6 5 - >3  +"
       "  A@( .   6 5    ";
int b(char*r,int s){
  for(int i=0;i<17;i++)
    if(a[i+s]-3==(r[0]^r[1]))
      return i/2+1;
  return 0;
}
#define c(p,r,i)(p+1)*b(r[i+1],i*17)/2
int main(int n,char**r){
  int x=b(r[1],0);
  printf("%d\n",x+c(x,r,1)+c(x,r,2)+c(x,r,3));
}

You need to supply four command line arguments - so for the first test case you need to run ./a.out Lo Ful "" ""

@ceilingcat Good job getting rid of the #define

@ceilingcat Good catch!

Go, 205 bytes
func c(s []string)int{f,l:=strings.IndexByte,len(s)
p:=f("UOEPM",s[0][0])+3
r:=p-1+p*(f("VOFDZ",s[1][0])+3)/2
if l>2{r+=p*(f("war o",s[2][1])+5)/2}
if l>3{r+=p*(f("it Ra",s[3][len(s[3])-2])+3)/2}
return r}

It's a callable function, takes runes as a slice of strings, e.g. []string{"Um", "Ful"}.
Try it on the Go Playground.

Haskell, 623 bytes
Using ADTs instead of numerical voodoo.
NOTE: Add  36 for {-# LANGUAGE GADTs,ViewPatterns #-}

Score is computed assuming that it is compiled/run with -XGADTs -XViewPatterns

data P=Lo|Um|On|Ee|Pal|Mon deriving(Enum,Read,Eq)
data E=Ya|Vi|Oh|Ful|Des|Zo deriving(Enum,Read,Eq)
data F=Ven|Ew|Kath|Ir|Bro|Gor deriving(Enum,Read,Eq)
data C=Ku|Ros|Dain|Neta|Ra|Sar deriving(Enum,Read,Eq)
data S where
  S::P->E->S
  Q::P->E->F->S
  R::P->E->F->C->S
k(a:b:x)=let{p=read a;e=read b}in case x of{[]->S p e;[c]->Q p e(read c);[c,d]->R p e(read c)(read d)}
c,d::Enum a=>a->Int
c=succ.fromEnum
d=(+2).fromEnum
e Bro=7
e x=(+2).d$x
f x|c x`elem`[1,5,6]=d x|2>1=c x
g p f x =(`div`2).(*f x).succ$c p
h(S x y)=c x+g x d y
h(Q x y z)=h(S x y)+g x e z
h(R x y z t)=h(Q x y z)+g x f t
main=print.h.k.words=<<getLine
Input: a single spell as a normal string
e.g.
Lo Ful
Um Ful
Multilining can be done by replacing the last line with
main=interact$unlines.map(show.h.k.words).lines
But this would add bytes to the count

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Playing with robots for kids - Which letter will I reach?

TL;DR: Given an array of chars and a robot in a starting position of the array, write an algorithm than can read a string with movements (F for "go forward", R for "rotate 90 degrees right" and L for "rotate 90 degrees left") and calculate the ending position of the robot. More details in the complete text.

We have at home a very simple programmable device for kids: a small vehicle with buttons to make the vehicle go forward, turn 90 degrees left or turn 90 degrees right. Something similar to this:

We also have a foam mat with letters like this:

The purpose of all this is to teach the kids both the alphabet and the rudiments of programming, all at once.
The challenge
Suppose we have randomly arranged our foam mat like this:
+---+---+---+---+---+---+---+
| E | R | L | B | I | X | N |
+---+---+---+---+---+---+---+
| O | A | Q | Y | C | T | G |
+---+---+---+---+---+---+---+
| F | W | H | P | D | Z | S |
+---+---+---+---+---+---+---+
    | K | V | U | M | J |
    +---+---+---+---+---+
            |   |
            +---+

Suppose also we have modified the vehicle so that when we program a "go forward" command, the vehicle goes forward exactly size of one square in the mat. So, if the vehicle is in the U square and goes north, it stops exactly in the P square.
The instructions are all given to the vehicle before it starts to move, and those are:

F: The vehicle goes forward into the next square.
R: The vehicle turns 90 degrees right in its place (no further movement).
L: The vehicle turns 90 degrees left in its place (no further movement).

Once the instructions are given, you can press the "GO" button and send the vehicle to a given position as it will follow every instruction in the given order. So, you can tell the kid to insert the needed instructions for the vehicle to go to a given letter.
You must write the shortest program/function that processes a string (input parameter) with a set of instructions and calculates the letter the vehicle stops over (output string).
Details:

The vehicle always starts at the blank square at the bottom, and facing north (towards the U square).
The input string will contain only the letters F, R, L and G (for the "go" button). You can use lowercase letters for the mat and the instructions, if you prefer so.
The algorithm must obey every instruction in the string before the first G (every instruction after that is ignored as the vehicle has started moving).
If the vehicle goes out of the mat at any given moment (even if the input string has not been completely processed), the algorithm must return the string Out of mat.
If not, the algorithm must return the letter the vehicle has stopped over. The starting point counts as a  char (or an empty string).

Examples:
Input: FFG
Output: P

Input: FRFRFG
Output: Out of mat

Input: RRFFG
Output: Out of mat

Input: FFFRFFLFG
Output: X

Input: FFFRFFLF
Output:      <-- Nothing or a whitespace (the robot has not started moving)

Input: FFFRRFFFG
Output:      <-- Nothing or a whitespace (the robot has returned to the starting point)

Input: RRRRRLFFFLFFRFRFGFFRRGRFF
Output: L    (Everything after the first G is ignored)

This is code-golf, so may the shortest program for each language win!

Next up: same thing, but with the mat configuration as string input, with @ being the starting position and spaces being off the mat, so this config would be ERLBIXN\nOAQYCTG\nFWHPDZS\n KVUMJ \n   @ (with different spacing, SE messed it up)

JavaScript (ES6), 194 176 169 163 bytes
Saved some bytes thanks to @Luke and @Arnauld.
s=>(p=35,d=3,t='ERLBIXN1OAQYCTG1FWHPDZS11KVUMJ11111 11',[...s].every(i=>i=='L'?d--:i>'Q'?d++:i<'G'?+t[p+=[1,8,-1,-8][d%4]]||!t[p]?p=1/0:p:0)?'':t[p]||'Out of mat')

Ungolfed:
s=>(
  p=35,
  d=3,
  t='ERLBIXN1OAQYCTG1FWHPDZS11KVUMJ11111 11',
  [...s].every(i=>i=='L'?d--:
                  i<'Q'?d++:
                  i<'G'?+t[p+=[1,8,-1,-8][d%4]]||!t[p]?p=1/0:p:
                  0
              )?'':
               t[p]||'Out of mat'
)

f=
s=>(p=35,d=3,t='ERLBIXN1OAQYCTG1FWHPDZS11KVUMJ11111 11',[...s].every(i=>i=='L'?d--:i>'Q'?d++:i<'G'?+t[p+=[1,8,-1,-8][d%4]]||!t[p]?p=1/0:p:0)?'':t[p]||'Out of mat')

console.log(f('FFG')); //P
console.log(f('FRFRFG')); //Out of mat
console.log(f('RRFFG')); //Out of mat
console.log(f('FFFRFFLFG')); //X
console.log(f('FFFRFFLF')); //(space)
console.log(f('FFFRRFFFG')); //(space)
console.log(f('RRRRRLFFFLFFRFRFGFFRRGRFF')); //L
console.log(f('FFFFFRRFG')); //Out of mat

You can save 3 bytes by replacing false with !1

Thanks, @Luke.  I can actually save a bunch of bytes by removing the "G" test altogether.  If it's not "L", "R", or "F" it can be assumed to be "G" (unless "G" is missing).  Either way, the every method handles it.

Here's a solution for 165 bytes: (s,p=35,d=3,t='ERLBIXN1OAQYCTG1FWHPDZS11KVUMJ11111 11')=>[...s].every(i=>i=='L'?d--:i=='R'?d++:i=='F'?+t[p+=[1,8,-1,-8][d%4]]||!t[p]?p=1/0:1:0)?'':t[p]||'Out of mat'

Not sure how that gets me to 165 bytes(?)  But I certainly don't need a separate variable for the [1,8,-1,-8] array, thanks!

Oops, must have miscounted, it's 171. I also removed a space you don't need, which still is in the current answer (it's the last space).

Of course, thanks!  Now down to 169 bytes.

@Arnauld, good points both!  The parentheses were left over from a previous more-complicated answer.

You can also do i<'G' instead of i=='F'.

Instead of doing t[p...]==1, you could do +t[p...]

Python 3, 226 231 241 bytes
Second edit; should work now. Again, plenty of optimization to be done.
n=input();s="0ERLBIXN00OAQYCTG00FWHPDZS000KVUMJ000000 00000";d=1;c=40;i=0;w=[-1,-9,1,9]
while n[i]!="G"and c>=0:
 if n[i]=="F":c+=w[d]
 else:d=[d+[-1,3][d<0],-~d%4][n[i]=="R"]
 i+=1
print(["Out of mat",s[c]][c in range(len(s))and s[c]!="0"])

Try it online!

Python 2, 235 bytes
x=0;y=1;a=4;b=3
p='ERLBIXN','OAQYCTG','FWHPDZS','aKVUMJ','aaa '
r=''
for i in input():
 if'G'==i:r=p[a][b];break
 elif'G'>i:
  b+=x;a-=y;
  if(-1<a<5)-1or(''<p[a][b:]<'a')-1:r='Out of mat';break
 else:x,y=[[y,-x],[-y,x]][i<'R']
print r

Try it online!

Wolfram Language/Mathematica, 300 Bytes
p=Re[(1-7I)#[[1]]]&;d=Drop;t=Throw;s=Switch;s[#,0,"Out of mat",_,StringPart["000 0000KVUMJ0FWHPDZSOAQYCTGERLBIXN",p@#]]&@Catch@Fold[If[MemberQ[d[d[Range[4,35],{2,5}],{7}],p@#],#,t@0]&@(s[#2,"F",#+{#[[2]],0},"R",#{1,-I},"L",#{1,I},_,t[#]]&)[#1,#2]&,{4,I},If[StringFreeQ["G"]@#,{"G"},Characters@#]&@#]&

Ungolfed:
p = Re[(1 - 7 I) #[[1]]] &;
d = Drop;
t = Throw;
s = Switch;
s[#,
    0, "Out of mat",
    _, StringPart["000 0000KVUMJ0FWHPDZSOAQYCTGERLBIXN", p@#]] &@
  Catch@
  Fold[
    If[MemberQ[d[d[Range[4, 35], {2, 5}], {7}], p@#], #,
        t@0] &@(s[#2, "F", # + {#[[2]], 0}, "R", # {1, -I},
          "L", # {1, I}, _, t[#]] &)[#1, #2] &,
    {4, I},
    If[StringFreeQ["G"]@#, {"G"}, Characters@#] &@#] &

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
A lean, mean bean machine
A classic example to introduce people to the concept of a discrete probability distribution is the bean machine. This machine has a large amount of marbles fall from a narrow passageway at the top, after which they hit rows of interlaced pins, where at each pin the marble hits it might fall to the left or the right of the pin. Finally, the pins are collected in vertical bins at the bottom of the machine. A simple diagram of this machine looks like this:
|     O     |
|     ^     |
|    ^ ^    |
|   ^ ^ ^   |
|  ^ ^ ^ ^  |
| ^ ^ ^ ^ ^ |
|_|_|_|_|_|_|

In this diagram, the O signifies the location from which the marbles fall. Each ^ is a pin at which the marble has a 50% chance to move to the square either to the left or the right of the pin. The marbles then gather at the bins on the bottom of the device, and for a large enough number of marbles, the height of the marble stacks in the bins will resemble a discrete binomial distribution.
Challenge
For this challenge, you will be calculating the resulting probability distribution of bean machines based on diagrams like the above one. The diagrams are interpreted as a two-dimensional 'program' that the marbles pass through, either towards fields at the side or fields below the current field. When the marbles reach the bottom of the machine they are counted for the probability distribution. To keep it interesting, these diagrams will contain a few more fields than just the simple source and pins. An example diagram is:
|     O     |
|     ^     |
|    ^ /    |
|   ^ | ^   |
|  <^- =  v |
| ^ ^ ^ ^ ^ |

Furthermore, the marbles now each have a rotation direction. This direction is set by some fields and determines to which next field the marble moves in several other fields.
The following fields are defined:

O: Source. Spawns marbles directly below it. The direction of these marbles is 50% left, 50% right. Each source produces the same amount of marbles.
U: Sink. Any marbles which enter this field are removed from the bean machine.
: Empty space. If a marble arrives at this field, it will move to the field below.
-: Floor. If a marble arrives at this field, it will move to either the field to the left or the field on the right, depending on its current direction.
^: Splitter. If a marble arrives at this field, it has a 50% of moving to the field to the right or the field to the left of the splitter. This also determines the direction of the marble.
v: Join. If a marble arrives at this field, it will move to the field below.
/: Slanted pad. If a marble arrives at this field, it will move to the field on the left of the pad, setting the direction of the marble.
\: Same as the previous, but to the right.
|: Reflector. If a marble arrives at this field, it will reverse the direction of the marble, and move the marble to the field to the right or the left, based on this reversed direction.
=: Cannon. If a marble arrives at this field, it will move it to the right or the left in the current direction, until the marble encounters a field that is not , - or O.
<: Same as the previous, but will always set the direction and move towards the left.
>: Same as the previous, but to the right.

The following guarantees are given regarding the diagram.

Each input row will have exactly the same length in fields.
The leftmost and rightmost field of each row will always be a |.
The diagram will not contain any possible paths through which marbles can get stuck in the machine for an indeterminate amount of iterations, like \/ or ^^.
The diagram will only contain the above mentioned fields.
There are one or more sources

Result
Your task will be to generate an 16-line tall ASCII bar graph of the probability distribution in which the marbles exit the bottom side of the graph, scaled so the largest probability covers all 16 characters. So for the following problem:
|     O     |
|     ^     |
|    ^ ^    |
|   ^ ^ ^   |
|  ^ ^ ^ ^  |
| ^ ^ ^ ^ ^ |

Your program should produce the following solution (note that it should have the same width as the input program, including the pipes to the side:
     # #
     # #
     # #
     # #
     # #
     # #
     # #
     # #
   # # # #
   # # # #
   # # # #
   # # # #
   # # # #
   # # # #
 # # # # # #
 # # # # # #

Examples
The following is an example that should test the functionality of all different field types:
|     O     O         |
|  O  ^ /  <^\\\      |
|    ^ >            ^ |
|   ^ ^ ^            =|
|  ^ ^ | ^    <^   O  |
| ^ > ^ | ^   O ^> v  |
||  ^U  ^  |  =    ^\ |
|  ^ ^ ^ ^U ^\ ---^   |
| = ^   ^     =    v  |

It should result in the following output:
                     #
                     #
                     #
                     #
                   # #
                   # #
                   # #
       # #         # #
       # #         # #
       # #         # #
       # #         # #
      ## #         # #
      ## # #       # #
   # ### # #       # #
 # # ### # #       # #
 # # ### # #       # #

Rules
Both functions and full programs constitute valid answers for this challenge. You will receive the diagram as a newline-separated string, and you should return the output graph in the given format. Default input/output rules apply. While trailing and leading newlines are allowed in the output, each row should have exactly the same width as the input.
As to allow more creative solutions, it is only required that your program outputs the correct result more than 90% of the time for the same diagram. It is a probability simulation after all.
Scoring
This is code-golf, so the lowest score in bytes wins.

Much simpler but related.

Comments are not for extended discussion; this conversation has been moved to chat.

so v = [space]?

@l4m2 v and [space] differ in how cannons interact around them.

Python 3, 431 429 410 bytes
def t(a):e=enumerate;p=a.split("\n");o=[0]*len(p[0]);{m(i,j,p,o,1):m(i,j,p,o,-1)for i,r in e(p)for j,c in e(r)if"O"==c};[print("".join(" #"[round(16*r/max(o)+i)>15]for r in o))for i in range(16)]
def m(r,k,p,o,l,x=1):
 while r<len(p):
  c=p[r][k]
  if"^"==c:x/=2;m(r,k-l,p,o,l,x)
  if"U"==c:return
  if c in" vO":r+=1;continue
  l=[1,l,-1,l,-l,1][ord(c)%6];k-=l
  while";"<c<"?"and p[r][k]in" O-":k-=l
 o[k]+=x

Try it online!
This answer is a collaborative effort between Wheat Wizard and CensoredUsername. For reference, this is the ungolfed algorithm.
-2 bytes from Mr. Xcoder
-19 bytes from CensoredUsername

-2 bytes if you switch to Python 2 (print statement)?

Of this was said: but I can confirm it's doable in 519 characters of python 3 code ;) I don't think I can golf mine much more - CensoredUsername

I was hopelessly naive when I said that. That said, the ensuring golfing competition was quite amusing. Also @cairdcoinheringaahing, python 2's print statement is a statement, not an expression and it can therefore not be used in a list comprehension. This would mean that the oneliner at the top has to be split up into several indented lines which would make the 2 byte gain from removing it void.

Python 2, 731 bytes
i=raw_input
l=i()
c=[]
while l:c,l=c+[l],i()
p=[[0]*len(l)for l in c]+[[0]*max(map(len,c))]
S=lambda r,C,p:r>=0and C>=0and r<len(p)and C<len(p[r])
def U(r,C,P,D,N=0):
 if S(r,C,p):p[r][C]+=P
 if S(r,C,c):
	K=c[r][C]
	if K in' O':U(r+1-N,C+D*N,P,D,N)
	elif'v'==K:U(r+1,C,P,D)
	elif'-'==K:U(r,C+D,P,D,N)
	elif'^'==K:U(r,C-1,P/2,-1);U(r,C+1,P/2,1)
	elif'/'==K:U(r,C-1,P,-1)
	elif'\\'==K:U(r,C+1,P,1)
	elif'='==K:U(r,C+D,P,D,1)
	elif'>'==K:U(r,C+1,P,1,1)
	elif'<'==K:U(r,C-1,P,-1,1)
	elif'|'==K:U(r,C-D,P,-D)
for r in range(len(c)):
 for C in range(len(c[r])):
	if'O'==c[r][C]:U(r+1,C,1.,1);U(r+1,C,1.,-1)
p=p[-1][::-1]
s=16/max(p)
f=['#'*min(int(n*s),16)+' '*min(int(16-n*s),16)for n in p]
print('\n'.join(map(''.join,zip(*f)))[::-1])

Try it online!
-17 bytes thanks to caird coinheringaahing
-12 bytes thanks to Nathan Shiraini
-56 bytes by switching to mixed indentation (Python 2)
-28 thanks to CensoredUsername because the probabilities are normalized in the end, so it's not necessary that the end probabilities always add up to 1.
-7 bytes thanks to Calculator Feline by using a shorter ending elif statement.
-218 bytes by merging the two functions

1052 bytes

@cairdcoinheringaahing Right, thanks.

In calls to R and L like R(r+1-N,C+N,P,N=N) (first call to R), you don't need the N= at the end; it should be R(r+1-N,C+N,P,N) instead.

@NathanShiraini Right, thanks.

... you forgot some. The last 2 line of both L and R ^^
Also, your second level of indentation is 4 spaces everywhere, I think you could make it 2.

@NathanShiraini Whoops, forgot about that (I Ctrl-F'd N=N :P). And also, those are tabs; the bytecount if you copy-paste might be different than what it actually is; the first level is 1 space and the second level is 1 tab :P

The elif K in'|\\' can probably be an else case for bytesaves.

@CalculatorFeline Unfortunately, not quite, because of the implicit ignoring of U, but I have shortened it following that idea. Thanks!

Another thing that might save bytes is that you can compare characters. > is shorter than ==.

You can remove another 4 bytes by using input and ask for the input to be surrounded by quotes (the norm for Python 2)

@cairdcoinheringaahing I can't outgolf the other answer that way anyway for now so I'll keep it til later when I might be able to use it to win. Thanks though :)

C, 569 568 556 Bytes
Golfed
#define A s[1]
#define c(i,j,k) break;case i:x=j;y=k;
w,S,i,j,d,x,y,z;main(int*a,char**s){w=strchr(&A[1],'|')+2-A;a=calloc(w,4);for(;i++<'~~';j=0){for(;A[j];){if(A[z=j++]==79){d=rand()%2;x=4;y=7;z+=w;for(;z<strlen(A);){z+=x%3-1+(y%3-1)*w;switch(A[z]){case 85:goto e;c(32,x/3*(3+1),y/3*(3+1))c(45,d*2+3,7)c(94,(d=rand()%2)*2+3,7)c(118,4,8)c(47,3,7)d=0;c(92,5,7)d=1;c(124,(d=!d)*2+3,7)c(60,x,y)case 62:d=A[z]/2%2;case 61:x=d*8;y=4;}}a[z%w]++;e:;}}}for(i=-1;++i<w;S=a[i]>S?a[i]:S);for(j=17;j-->1;puts(""))for(i=0;i<w-1;printf("%c",a[i++]*16./S+0.6<j?32:35));}

Ungolfed
//Variable Definitions
//direction - marbles current direction, 0 -> left, 1-> right
//arrwidth - width of array
//x - change in x of marble in base 3 - 0 -> Left, 1 -> stay, 2-> right
//y - change in y of marble in base 3 - 0 -> Up, 1 -> stay, 2-> Down
//z - position of marble
//i - iterator on runs of program
//j - iterator on string
//k - iterator on outputstring
//argc - array holding all buckets

#define c(i,j,k) break;case i:x=j;y=k;

arrwidth,scale,i,j,direction,x,y,z;

main(int *argc, char**argv){
  arrwidth=strchr(&A[1],'|')+2 - A; //get width
  argc=calloc(arrwidth,4);
  for(;i++<'~~';j=0){
    for(;A[j];){
      if(A[z=j++] == 79){ //if it finds an O, start sim
        direction=rand()%2;
        x=4;
        y=7;
        z+=arrwidth;
        for(;z<strlen(A);){
          z+=x%3-1 + (y%3-1)*arrwidth;
          switch (A[z]){
            case 85://marble dies dont record
              goto e;
            c(32,x/3*(3+1),y/3*(3+1)) //case ' '
            c(45,direction*2+3,7)    //case -
            c(94,(direction=rand()%2)*2+3,7)    //case ^
            c(118,4,8)    //case v
            c(47,3,7)    //case /
              direction=0;
            c(92,5,7)   //case '\'
              direction=1;
            c(124,(direction=!direction)*2+3,7)
            c(60,x,y)    //case <
            case 62:    //case >
              direction=A[z]/2%2;
            case 61:  //case =
              x=direction*8;
              y=4;
          }
        }
        argc[z%arrwidth]++;
        e:;
      }
    }
  }
  //get output answer in terms of '#'
  for(i=-1;++i<arrwidth;scale=argc[i]>scale?argc[i]:scale);
  for(j=17;j-->1;puts(""))
    for(i=0; i < arrwidth-1;printf("%c",argc[i++]*16./scale+0.6<j?32:35));
}

Edits
Saved 12 bytes by changing my case macro.
Notes
My code uses a system of base 3 integers to determine where the marble is headed and will be headed after (for cannons and stuff).
I tried so had to beat that python solution, I really did.

I count 568 bytes; maybe you counted the trailing newline? And darn I feel bad; outgolfed in Python by C? Jeez... :P

You are correct, I left a trailing newling in the file. thanks!


text:
The dragon Curve sequence
The dragon curve sequence (or the regular paper folding sequence) is a binary sequence.  a(n) is given by negation of the bit left of the least significant 1 of n.  For example to calculate a(2136) we first convert to binary:
100001011000

We find our least significant bit
100001011000
        ^

Take the bit to its left
100001011000
       ^

And return its negation
0

Task
Given a positive integer as input, output a(n). (You may output by integer or by boolean).  You should aim to make your code as small as possible as measured by bytes.
Test Cases
Here are the first 100 entries in order
1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 0 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 0 1 1 0 0 1 0 0 0 1 1 0 1

someway related

The least significant bit of 100001011000 is a 0. Do you mean the least significant 1?

Mathematica 25 Bytes
1/2+JacobiSymbol[-1,#]/2&

Other ways of doing this:
56 bytes
(v:=1-IntegerDigits[#,2,i][[1]];For[i=1,v>0,i++];i++;v)&

58 bytes
1-Nest[Join[#,{0},Reverse[1-#]]&,{0},Floor@Log[2,#]][[#]]&

Wow! A mathematica answer and it's not builtin only. Have an upvote!

The only thing that could make this answer even better is an explanation for why and how it works. :P

@MartinEnder https://arxiv.org/pdf/1408.5770.pdf See the remark after Example 13.

Python 3, 22 21 bytes
1 byte thanks to ETHproductions.
lambda n:n&2*(n&-n)<1

Try it online!
Bitwise arithmetic ftw.

"You may output by integer or by boolean" so I guess you don't need the 0+(...)?

The order of operations here is really confusing me. Could n&1 be put in parentheses? Or is is 1+(n^~-n)<1 that can be put in parentheses? Or is it 1+(n^~-n)...

oh god what. this is what I was looking for :o nice!

& has the lowest precedence, so it is 1+(n^~-n)

Ah, found the precedence table. Now it all makes sense :P

@ETHproductions done.

So how does it work?

Retina, 38 34 29 bytes
\d+
$*
+`^(1+)\1$|1111
$1
^1$

Try it online!
Martin and Leaky essentially came up with this idea, for 5 more bytes off!
Converts the input to unary, and then progressively divides the number by 2. Once it can't do that evenly anymore (i.e. the number is odd) it then removes patches of 4 from the input, computing the result of the last operation mod 4. Finally, this checks if the result was 1, which means that digit to the left of the least significant 1 bit was zero. If that is true, the final result is 1, otherwise it is zero.

31 bytes (should I post it myself?)

I found a way to avoid the full binary conversion and instead just divide out the factors of 2 and check for equality with 1 (mod 4): https://tio.run/##K0otycxL/K@q4Z7wPyZFm0tFi0s7IU7DUFszxlClxhAIuFQMueIMVf7/N@Qy4jLmMuEy5TLjMuey4LLkMjTgMjI0NgMA

@MartinEnder essentially my algorithm... with 2 bytes off

@LeakyNun Oh yeah, they're both the same idea. Great minds and stuff... ;)

I'll edit that in, but if either of you wants to post it I'll revert, as I probably wouldn't have thought of that myself ;)

Jelly, 5 bytes
&N&HṆ

Try it online!
How it works
&N&HṆ  Main link. Argument: n

 N     Negate; yield -n.
&      Bitwise AND; compute n&-n.
       This yields the highest power of 2 that divides n evenly.
   H   Halve; yield n/2.
  &    Bitwise AND; compute n&-n&n/2. This rounds n/2 down if n is odd.
    Ṇ  Take the logical NOT of the result.

Alice, 8 bytes
I2z1xnO@

Try it online!
Takes input as the code point of a Unicode character and outputs the result as a 0x00 or 0x01 byte accordingly.
For testability, here is a decimal I/O version at 12 bytes which uses the exact same algorithm (only I/O is different):
/o
\i@/2z1xn

Try it online!
If Alice was a golfing language and didn't require explicit I/O and program termination, this would clock in at a mere 5 bytes (2z1xn) beating both 05AB1E and Jelly.
Explanation
I    Read input.
2z   Drop all factors of 2 from the input, i.e. divide it by 2 as long
     as its even. This shifts the binary representation to the right
     until there are no more trailing zeros.
1x   Extract the second-least significant bit.
n    Negate it.
O    Output it.
@    Terminate the program.

Haskell, 33 bytes
g~(a:b:c)=1:a:0:b:g c
d=g d
(d!!)

Try it online!
Uses 0-indexing.

What does the ~ do in this context?  I get that it is a lazy match, but why do you need a lazy match?

Haskell, 26 bytes
f n=even$div n$2*gcd(2^n)n

Try it online!
Boolean output.
32 bytes
(d!!)
d=d%1
~(h:t)%k=k:h:t%(1-k)

Try it online!
Saves one byte off of Anders Kaseorg's recursive-list solution.

APL (Dyalog Unicode), 24 23 21 bytes
{~⍵[¯1+⌈/⍸⍵]}0,2⊥⍣¯1⊢

Try it online!
Bitwise operations are a bit long in APL, so I went with the method in the question.
-1 byte from dzaima.
-2 bytes from Adám.
Explanation
{~⍵[¯1+⌈/⍸⍵]}0,2⊥⍣¯1⊢ input n taken on the right
               2⊥⍣¯1⊢ n in binary
             0,       with 0 prepended in case the LSB is at first index
{           }         do the following to the array ⍵:
         ⍸⍵           get indices of 1's in ⍵
       ⌈/             find maximum index
    ¯1+               subtract 1 from it to get the previous index
  ⍵[       ]          Find the element at that index in ⍵
 ~                    bitwise NOT

2(⊥⍣¯1)⊢ -> 11⎕dr⊢ and maybe rm 0,

@ngn 11⎕DR doesn't work because the chunks of 8 bits are in LSByte-first order, which is quite different from the result of 2⊥⍣¯1.

@Bubbler right, ⎕dr here requires an assumption that the machine is big-endian

C (gcc), 20 bytes
f(n){n=!(n&-n&n/2);}

Try it online!

This doesn't actually "work"; you are relying on a quirk of the code generator for one particular version of the compiler targeting one particular architecture, where intermediate calculations are done in the same register that is used for return values. Enabling any type of optimization, changing the target architecture, or using a different version of GCC will break this. You might as well just say "the garbage on my stack contains the right output when there is a full moon on October 13th".

While everything you say is true and code like this never be used in production code, we define languages by their implementations for the purposes of code golf. Without additional flags, this works in all recent versions of gcc and tcc, and it only has to work in one version to be considered valid.

"we define languages by their implementations for the purposes of code golf" Wait, what? So every compiler flag and every version of GCC defines a different language? You realize that's crazy, right? The C language standard is what defines the language.

Not here. If there was a C standard but no implementation, we wouldn't even consider it a language. As I said before, the compiler defines the language. As a result, relying on undefined behavior is allowed. A different set of flags isn't considered a different language, but unless you add them to your byte count, all answers use standard compilation flags.

Wow. That's nuts. I mean, I could understand if you were saying that implementation-defined behavior is allowed, but undefined behavior is not defined by the implementation. It is literally undefined. The implementation is allowed to do random things each time. And this notion of "standard compilation flags" is something that you just invented. My standard compilation flags include several that break your code. And I hardly think the optimizer is non-standard. Well, clearly this site is not for me.

I'm not talking about your or my standard compilation flags; I mean the bare minimum you need to produce an executable. With C and gcc, that simply gcc <filename>. If you want to turn on optimizations, affect error checking either way, or include additional libraries, they contribute to your byte count. -- If you don't want to use UB in your answers, no problem. We're all here to have fun, but that means different things for different people. For me, that means twisting the language in any imaginable way to squeeze out the last byte.

Sure, I enjoy twisting the language in any imaginable way to squeeze out the last byte. But, as I said initially, what you're doing here is tantamount to saying the garbage on your stack contains the right output under a certain set of arbitrary conditions. That strikes me as anti-competitive (I'd say 'cheating', but you said the 'rules' explicitly allow this, so clearly it can't be cheating, but it definitely rubs me wrong.) I realize I'm free to do whatever I want, but I don't like playing games whose rules encourage nonsense submissions. There's nothing "fun" in trying to reason about UB.

INTERCAL, 50 bytes
DOWRITEIN.1DO.1<-!?1~.1'~#1DOREADOUT.1PLEASEGIVEUP

INTERCALs unary operators are quite suitable for this, so I decided to write my first post.
DO WRITE IN .1
DO .1 <- !?1~.1'~#1
DO READ OUT .1
PLEASE GIVE UP

05AB1E, 6 bytes
b0Ü¨θ≠

Try it online!

Wise, 28 20 16 bytes
::-~^~-&:[?>]~-^

Try it online!
Explanation
This is a port of Leaky Nun's Python answer.  It unfortunately does not work on TIO because TIO's version of the interpreter is a bit outdated.
We start by making 3 copies of our input with ::, we then decrement the top copy by 1.  This will flip all the bits up until the first 1.  We then xor this with another copy of our input.  Since all of the bits up until the first 1 on our input have been flipped this will result in all those bits being 1 on the result.  If we then add one ~- to the result we will get a single 1 at the place to the left of our least significant 1.  We AND this with the input to get that bit from the input.  Now we will have 0 iff that bit was off and a power of 2 iff that bit was on, we can change this into a single 1 or 0 with :[?>].  Once this is done we need only negate the bit ~-^ and we are done.

Haskell, 45 43 39 bytes
6 bytes saved thanks to nimi
f x|d<-div x 2=[f d,mod(1+d)2]!!mod x 2

Try it online!

You can use div instead of quot.

Even better: divMod: f x|(d,m)<-divMod x 2=[mod(1+d)2,f d]!!m

@nimi I don't even understand how that works.  You should probably just post it yourself.

It's still the same algorithm, but just a different way to pick the branch (recursively call f again vs. base case), so feel free to edit it in. |(d,m)<-divMod x 2 is a pattern guard to bind d to div x 2 and m to mod x 2. We use m to index the two element list [...,...]!!m. In case of m==0 we return mod(1+d)2 and in case of m==1 f d.

Oh, div+ mod is still shorter than divMod: f x|d<-div x 2=[mod(1+d)2,f d]!!mod x 2

@nimi That doesn't seem to work.  It seems to have an offset of one.

Oh, sorry, you have to flip the list elements: [f d,mod(1+d)2]. Try it online!.

x86 Machine Code, 17 16 15 bytes:
Assumes an ABI where parameters are pushed on the stack and the return value is in the AL register.
8B 44 24 04 0F BC C8 41 0F BB C8 0F 93 C0 C3

This is disassembled as follows:
_dragoncurve:
  00000000: 8B 44 24 04        mov         eax,dword ptr [esp+4]
  00000004: 0F BC C8           bsf         ecx,eax
  00000007: 41                 inc         ecx
  00000008: 0F BB C8           btc         eax,ecx
  0000000B: 0F 93 C0           setae       al
  0000000E: C3                 ret

That looks like 366 bytes to me

@PeterTaylor I'm counting the size of the CPU instruction in bytes for my answer; that's a pretty common practice on PPCG for assembly answers.

I couldn't say how common it is, but it is definitely wrong

@PeterTaylor That was an easy fix. It seems pedantic since the accepted solution is to just post the string of CPU instructions and call it "machine code" rather than assembly. The answers also highly recommend including a disassembly of the instructions in your answer.

It isn't just pedantic, it's also meaningless. There is no distinction between "machine code" and "assembly code" as far as a computer is concerned. The difference is merely one of interpretation. We assign mnemonics to machine code bytes to make them easier for humans to read. In other words, we ungolf the bytes to make them easier to understand.

I don't think this is quite right, though. You are intending to return only a single byte, in AL, but you claim to be returning the result in EAX. That means you'll have garbage in the upper bytes. So you'll either have to add extra code that clears those, or declare that you're returning a Boolean in the lower 8 bits (which would be AL). Hopefully that made sense; it's kind of hard to explain. Basically, just change the answer to say "return value is a Boolean in AL". And I'm not sure why you need BTC. BT would work just as well, since you're clobbering the input anyway.

@CodyGray Huh. Because of that comment I just went and re-read the documentation of SETcc thoroughly and it doesn't say anything about zeroing upper bytes of larger registers - it works on my machine, though. Updated my answer.

No, it absolutely does not zero the upper bytes! That has always been a serious PITA with SETcc, in fact, because of the possibility for partial register stalls that it introduces. Putting golfing aside for a moment, the standard idiom is to XOR the entire 32-bit register in advance, if possible, but you have to do it before you set the flags. If that's not possible, you can MOVZX eax, al after the SETcc. Or, sometimes you see a MOV eax, 0 inserted immediately before the SETcc, since moves don't touch flags. I'd swear there was a detailed SO answer on this, but I can't find it.

@CodyGray Good to know for sure. I updated my answer to say the return value is in AL though, so a C prototype for this function would expect it to return a char and not an int - no harm done.

@CodyGray, there's a massive difference. Assembly code can't be executed: it has to be assembled, and the output executed.

That is irrelevant, @Peter. The assembly code is just a human-readable translation of machine code. They are exactly the same language, just in two different forms/representations. It's no different than TI BASIC, where it is commonly accepted that we count tokens, instead of character bytes, because this is how the system stores them internally. The same would be true with assembly language: the instruction mnemonics are not stored as individual characters, but rather represented as bytes of equivalent machine code.

Besides, practically speaking, why would anyone ever enter expanded assembly language mnemonics in a code-golf competition, when they could translate them into 100% equivalent machine code, where the entry is guaranteed to be shorter for free? That alone makes a distinction between the two pointless, if not entirely absurd.

@CodyGray, how the system stores them internally is precisely the point. You don't pass machine code to NASM or GAS: you pass a text file. For consistency with every other language, that text file is the file whose length needs to be counted. The argument you're making is exactly the same argument that some people make in favour of gzipped versions of Python or whatever, to which the answer is: make an interpreter which operates on that, defining a new language, and claim that your file is in that new language.

There seems to me a very clear difference here between gzipped versions of Python and what I'm talking about, where these are literally two sides of the same coin, but okay. Whatever. We can play the game of labeling it "machine code" if it makes people feel better. That's just not the canonical name or representation, which makes the answers harder to find and harder to understand, and also effectively means that no one will ever enter an assembly-lang entry. But I guess I also play code golf differently than others. Creating a brand new language seems like cheating/missing the point to me.

Similar idea, same score in SysV ABI

In fact if you combine SysV ABI with (char) return, then you can save 1 byte.

Python 2, 19 bytes
lambda n:n&-n&n/2<1

Try it online!

JavaScript (ES6), 17 14 bytes

f=
n=>!(n&-n&n/2)
<input type=number min=0 oninput=o.textContent=f(this.value)><pre id=o>

Edit: Saved 3 bytes by porting @Dennis's answer once I noticed that boolean output was acceptable.

Jelly, 7 6 bytes
1 byte thanks to Erik the Outgolfer.
Bt0ṖṪṆ

Try it online!
Longer programs

7 bytes: Họ¡2&2Ị
7 bytes: Bt0ṫ-ḄỊ

Hmm...well, you can just do ṖṪṆ (as my deleted answer) instead of ṫ-ḄỊ.

Another one for your 7-byte list: BUḌDḊḢ¬

Befunge-98, 19 bytes
&#;:2%\2/\#;_;@.!%2

Try it online!
&#                       Initial input: Read a number an skip the next command
  ;:2%\2/\#;_;           Main loop: (Direction: East)
   :2%                    Duplicate the current number and read the last bit
      \2/                 Swap the first two items on stack (last bit and number)
                          and divide the number by two => remove last bit
         \                swap last bit and number again
          #;_;            If the last bit is 0, keep going East and jump to the beginning of the loop
                          If the last bit is 1, turn West and jump to the beginning of the loop, but in a different direction.
&#;           @.!%2      End: (Direction: West)
&#                        Jump over the input, wrap around
                 %2       Take the number mod 2 => read the last bit
               .!         Negate the bit and print as a number
              @          Terminate

Octave, 34 bytes
@(x)~(k=[de2bi(x),0])(find(k,1)+1)

Try it online!
Explanation:
@(x)                               % Anonymous function taking a decimal number as input
    ~....                          % Negate whatever comes next
     (   de2bi(x)   )              % Convert x to a binary array that's conveniently
                                   % ordered with the least significant bits first
        [de2bi(x),0]               % Append a zero to the end, to avoid out of bound index
     (k=[de2bi(x),0])              % Store the vector as a variable 'k'
                     (find(k,1)    % Find the first '1' in k (the least significant 1-bit)
                               +1  % Add 1 to the index to get the next bit
     (k=[de2bi(x),0])(find(k,1)+1) % Use as index to the vector k to get the correct bit

How come I never heard of de2bi... :O

,,,, 10 9 bytes
::0-&2*&¬

Explanation
Take input as 3 for example.
::0-&2*&1≥
               implicitly push command line argument       [3]
::             duplicate twice                             [3, 3, 3]
  0            push 0 on to the stack                      [3, 3, 3, 0]
   -           pop 0 and 3 and push 0 - 3                  [3, 3, -3]
    &          pop -3 and 3 and push -3 & 3 (bitwise AND)  [3, 1]
     2         push 2 on to the stack                      [3, 1, 2]
      *        pop 2 and 1 and push 2 * 1                  [3, 2]
       &       pop 2 and 3 and push 2 & 3                  [2]
        ¬      pop 2 and push ¬ 2 (logical NOT)            [0]
               implicit output                             []

tinylisp, 71 bytes
(load library
(q((x)(not(nth(c 0(to-base 2 x))(last-index(to-base 2 x)1

Anonymous function that takes a number and returns 0 or 1. Try it online!
Ungolfed/explanation
Surprisingly, tinylisp's library lets us implement the spec almost directly.
(load library)

(lambda (x)                   ; Anonymous function with one argument
  (not                        ; Logical negation of
    (nth                      ; The element of _ at index __:
      (cons 0 (to-base 2 x))  ; The binary representation of x with a 0 prepended
      (last-index             ; Index of the last occurrence
        (to-base 2 x)         ; in the binary representation of x
        1)))))                ; of 1

Prepending a 0 handles the "previous bit" logic by shifting all elements down one spot, and it keeps us from walking off the left end of the list when there is only a single 1 bit.

C (gcc), 35 31 bytes
f(x){return~x&1?f(x/2):!(x&2);}

Switched to a recursive implementation.
Try it online!

Java 8, 17 bytes
n->(n&2*(n&-n))<1

Straightforward port of LeakyNun's Python 3 answer. I'm not familiar enough with bitwise operations and operator precedence to see a shorter solution; maybe there's a way to avoid the extra parentehesis?

MATL, 11 10 bytes
t4*YF1)Z.~

Try it online! Or see the first 100 outputs.
Explanation
t    % Implicit input. Duplicate
4*   % Multiply by 4. This ensures that the input is a multiple of 2, and
     % takes into account that bit positions are 1 based
YF   % Exponents of prime factorization
1)   % Get first exponent, which is that of factor 2
Z.   % Get bit of input at that (1-based) position
~    % Negate. Implicit display

Submission:
Python 2, 41 39 bytes
x=input()
while~-x&1:x/=2
print 1-x/2%2

Try it online!
-2 bytes thanks to FryAmTheEggman
Initial Solution:
Python 2, 43 bytes
lambda x:1-int(bin(x)[bin(x).rfind('1')-1])

Try it online!

So which one is your submission?

@LeakyNun The first one because it's shorter; the second one was my original submission. Should I post them separately?

~-x&1 works for the while condition instead, I think.

(I forget the username); I rejected your edit because edits to golf other people's code is not advised on PPCG. You can post suggestions (btw, thanks @FryAmTheEggman), but please do not make golfing edits. Thanks!

@StewieGriffin Ah yes, thanks. Unfortunately I can't ping the user because the edit was rejected.

Pari/GP, 20 bytes
n->kronecker(-1,n)>0

Using the Kronecker symbol.
Try it online!

SCALA, 99(78?) chars, 99(78?) bytes
if(i==0)print(1)else
print(if(('0'+i.toBinaryString).reverse.dropWhile(x=>x=='0')(1)=='1')0 else 1)

where i is the input.
As you can see, I do save 21 bytes if I don't take care of the zero (as the author did in his test case) :
print(if(('0'+i.toBinaryString).reverse.dropWhile(x=>x=='0')(1)=='1')0 else 1)

This is my first codegolf so I hope I did well :)
Try it online! Though it's quite long to compute lol.

Welcome to the site!

Chip, 93 bytes
HZABCDEFG,t
 ))))))))^~S
H\\\\\\\/v~a
G\\\\\\/v'
F\\\\\/v'
E\\\\/v'
D\\\/v'
C\\/v'
B\/v'
A/-'

Takes input as little endian bytes. (The TIO has a bit of python that does this for you). Gives output as either 0x0 or 0x1. (The TIO uses xxd to inspect the value).
Try it online!
How do it this?
Chip looks at input one byte at a time, so handling multibyte input adds some bulk, but not near as much as I had feared.
Let's go into it:
HZABCDEFG

These are HZ, high bit of the previous byte (if there was one), and A-G, the seven lower bits of the current byte. These are used to locate the lowest set bit of the number.
        ,t
))))))))^~S

When the lowest set bit is found, we have a few things to do. This first chunk says "if we have a set bit (the )'s), then stop Suppressing the output, and terminate after we print the answer.
H\\\\\\\/v~a
G\\\\\\/v'
...
A/-'

Whichever bit of the current byte (A-H) is only preceded by a bunch of zeroes then a one (\ and /: these look at the bits directly north of them; we can trust that all previous bits were zero) is passed through to the wires on the right (v, ', ...), then whichever value it is is inverted and given as the low bit of output (~a).

APL (Dyalog Extended), 12 bytes
1≠¯1⊥2↑⍸∘⌽∘⊤

Try it online!
Took the idea of using ⍸ from Razetime's answer.
How it works
1≠¯1⊥2↑⍸∘⌽∘⊤  ⍝ Input: n
           ⊤  ⍝ Binary representation of n
         ⌽∘   ⍝ Reverse
       ⍸∘     ⍝ Get indices of ones, in increasing order
              ⍝   LSB index (l) comes first, and the next number is l+1
              ⍝   iff the bit on the left of LSB is also 1
     2↑       ⍝ Take first two numbers, filling with 0 if too short
  ¯1⊥         ⍝ From [a, b] compute -a + b
1≠            ⍝ Is it not equal to 1?

Equivalent non-extended program:
APL (Dyalog Unicode), 17 bytes
1≠¯1⊥2↑∘⍸∘⌽2∘⊥⍣¯1

Try it online!

Husk, 10 8 bytes
¬!2↓¬↔Θḋ

Try it online!
¬          # logical NOT of
 !2        # the second element
   ↓¬      # after chopping-off initial zeros
     ↔     # of the reverse of
      Θḋ   # the binary digits of the input

K (ngn/k), 12 bytes
~1=-/|-2#&2\

Modeled after @Bubbler's APL answer.

2\ convert input to base-2
-2#& get the last two indices containing 1's
-/| subtract the smaller index from the larger one
~1= if the last truthy index isn't preceded by another truthy value, return 0. otherwise, return 1

Try it online!

Stax, 5 bytes
éò/ú╗

Run and debug it

Vyxal, 6 bytes
b0PṪt⌐

Try it Online!
b      # Convert to binary
 0P    # Strip zeroes
   Ṫt  # Second-to-last item
     ⌐ # The NOT of that

tinylisp, 83 bytes
(load library
(d F(q((x)(i(h x)x(F(t x
(d G(q((x)(- 1(h(t(F(reverse(c 0(to-base 2 x

Try it online!
fixed with dlosc's help.

Doesn't work for powers of 2--you'll want to cons a 0 to the front of the binary representation before reversing it, I think.

Also, def can be d.

Japt, 10 8 9 bytes
!+¢g¢a1 É

Try it online!
Explanation
!+¢   g    a1 É
!+Us2 gUs2 a1 -1 # Implicit input (U) as number
!+               # Return the boolean NOT of
      g          #   the character at index
       Us2       #     the input converted to binary
           a1    #     the index of its last 1
              -1 #     minus 1
      g          #   in string
  Us2            #     the input converted to binary

This returns false for everything because the character (0 or 1) is always a string.

Oops, should've noticed that... Fixed now

Looks like it fails for 1 now.

JavaScript (ES6), 53 34 bytes
a=>eval("for(;~a&1;a/=2);~a>>1&1")

42 bytes: a=>!+(a=a.toString(2))[a.lastIndexOf(1)-1]

I already found a shorter (mathematical) solution...

Nice :) Mind if I post that 42 byte one?

@Shaggy, no not at all

PHP>=7.1, 32 bytes
<?=1^!trim(decbin($argn),0)[-2];

PHP Sandbox Online
PHP, 40 bytes
for($i=$argn;$i%2<1;)$i/=2;echo$i/2%2^1;

Try it online!
PHP, 41 bytes
<?=1^preg_match("#110*$#",decbin($argn));

Try it online!

Common Lisp, 56 bytes
(defun f(n)(if(oddp n)(- 1(mod #1=(ash n -1)2))(f #1#)))

Try it online!

MMIX, 24 bytes (6 instrs)
00000000: 36ff0000 c8ffff00 3bffff01 c80000ff  6”¡¡Ṁ””¡;””¢Ṁ¡¡”
00000010: 73000001 f8010000                    s¡¡¢ẏ¢¡¡

Disassembled
dragon  NEGU $255,0,$0      // t = -n
        AND  $255,$255,$0   // t &= n (gets last 1 bit)
        SLU  $255,$255,1    // t <<= 1
        AND  $0,$0,$255     // n &= t
        ZSZ  $0,$0,1        // n = !n
        POP  1,0            // return n

Japt -!, 6 bytes
&n)Ñ&U

Try it
&n)Ñ&U     :Implicit input of integer U
&          :Bitwise AND of U with
 n         :Its negation
  )        :Group that together
   Ñ       :Multiply by 2
    &U     :Bitwise AND with U