Triangular numbers count the number of objects that can form an equilateral triangle. The nth triangular number forms an equilateral triangle with n dots on each side (including the vertices).
Here is a graphic example for the triangular numbers of 1 to 5:
```
n=1: triangular number: 1
*

n=2: triangular number: 3
 *
* *

n=3: triangular number: 6
  *
 * *
* * *

n=4: triangular number: 10
    *
   * *
  * * *
 * * * *
 
 n=5: triangular number: 15
      *
     * *
    * * *
   * * * *
  * * * * *
```

Your task is to implement a function ```triangular_range(start, stop)``` that returns a dictionary of all numbers as keys and the belonging triangular numbers as values, where the triangular number is in the range start, stop (including start and stop).
For example, ```triangular_range(1, 3)``` should return ```{1: 1, 2: 3}``` and ```triangular_range(5, 16)``` should return ```{3: 6, 4: 10, 5: 15}```.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Mathematics

Starter code: def triangular_range(start, stop):
	

Solutions:
def triangular_range(start, stop):
	return {i: i * (i + 1) / 2 for i in range(stop) if start <= i * (i + 1) / 2 <= stop}


from math import ceil

def root(n):
	return ((1 + 8 * n) ** 0.5 - 1) / 2

def triangular_range(s, e):
	return {i: -~i * i >> 1 for i in range(ceil(root(s)), int(root(e)) + 1)}


def triangular_range(start, stop):
	n = t = 1
	result = {}
	while t <= stop:
		if t >= start:
			result[n] = t
		n += 1
		t = n * (n + 1) // 2
	return result


from math import ceil, floor, sqrt

def triangular(n):
	return n * (n + 1) / 2

def quadratic_root(t):
	return (-1 + sqrt(1 + 8 * t)) / 2

def triangular_range(start, stop):
	first = int(ceil(quadratic_root(start)))
	last = int(floor(quadratic_root(stop)))
	result = {}
	t = triangular(first)
	for n in range(first, last + 1):
		result[n] = t
		t += n + 1
	return result


def triangular_range(start, stop):
	startn = int(math.ceil(-0.5 + math.sqrt(0.25 + 2 * start)))
	stopn = int(math.floor(-0.5 + math.sqrt(0.25 + 2 * stop)))
	return dict(((n, n * (n + 1) / 2) for n in range(startn, stopn + 1)))


def tri(number):
	return int(number * (number + 1) / 2)

def quadsol(number):
	return int((math.sqrt(8 * number + 1) - 1) / 2)

def triangular_range(start, stop):
	return {x: tri(x) for x in range(quadsol(start), quadsol(stop) + 1) if tri(x) in range(start, stop + 1)}


from bisect import bisect_left, bisect_right
memo = [0, 1]

def triangular_range(start, stop):
	while memo[-1] <= stop:
		memo.append(memo[-1] + len(memo))
	return {i: memo[i] for i in range(bisect_left(memo, start), bisect_right(memo, stop))}


from math import sqrt

def triangular_range(start, stop):

	def get_n(sum):
		a = int(round((sqrt(8 * sum) - 1) / 2, 0))
		return a
	return {n: int(n * (n + 1) / 2) for n in range(get_n(start), get_n(stop) + 1) if start <= int(n * (n + 1) / 2) <= stop}


def triangular_range(start, stop):
	return {n: n * (n + 1) // 2 for n in range(int(start ** 0.5), stop) if start <= n * (n + 1) // 2 <= stop}


def triangular_range(start, stop):
	dict = {}
	for trial in range(1, stop + 1):
		triangle_num = sum(range(trial + 1))
		if start <= triangle_num <= stop:
			dict[trial] = triangle_num
	return dict