The simplest linear regression formula for two continuous variables is as follows:
The slope for this linear function is denoted with b and the intercept with a. When calculating these values, you try to find the line that fits the data points the best, where the deviations from the line are the smallest. The formula for the slope is as follows:
Once you have the slope, it is easy to calculate the intercept, as shown here:
The decision regarding which variable is dependent and which independent is up to you. Of course, this also depends on the problem you are trying to solve, and on common sense. For example, you would probably not model gender as a dependent variable of income, but would do the opposite. The formulas don't tell you that. You actually calculate two formulas, name the first regression line and the second regression line, with both variables playing a different role in each equation.
Here is the calculation of both slopes...