Question: I'm developing a shop system and using this method to store the customers with their respective orders:

```
try
{
    $connection = new PDO("mysql:host={$HOST};dbname={$DB_NAME}", $USERNAME, $PASS);
}

$connection->beginTransaction();
$sql = "INSERT INTO orders (customer_id, customer_name, order_value, order_date)
        VALUES (?, ?, ?, ?)";

$query = $connection->prepare($sql);
$query->execute(array
(
    $user_id,
    $user['user_name'],
    $order_value,
    $date
));

$id_of_respective_order = $connection->lastInsertId();

$sql = "INSERT INTO purchased_products (order_id, product_name, product_price, quantity)
        VALUES (?, ?, ?, ?)";

$query = $connection->prepare($sql);

foreach($_SESSION['cart'] as $product)
{
    $query->execute(array
    (
        $id_of_respective_order,
        $product['product_name'],
        $product['product_price'],
        $product['quantity']
    ));
}

$connection->commit();

```

By using this, later I can show all the products that belongs to their respective customers by using the `Foreign Key` `order_id`.

My question is simple: is this secure? If many people buy at the same time can I have problems? Is there a possibility of a product being directed to the wrong customer? Can I trust in this method?

Answer: 
As others pointed out in comments (and as usual), an iterative solution can be better. But you said you want to practice recursion, so I guess you want to stick with that.

This code:

> 
> 
> ```
> int(ceil(len(lis))/2)
> 
> ```
> 
> 

Is exactly the same as:

```
len(lis) // 2

```

Because, there's no point taking the ceiling of a list length, as it's always an integer. And you can use `//` to divide and throw away the remainder, which is the same thing as casting a floating point number to integer, but shorter and simpler.

You should not duplicate code. You should put the result of the above calculation only once, save it in a variable and reuse it when creating `A` and `B`.

Similarly, instead of duplicating the logic when creating `ISA` and `ISB`, it would be better to put the common logic into a function.

Some more meaningful variable and function names would be good too.
Since we can assume without loss of generality that the missing number is not on the ends of the list, let's assume that the numbers are: `a, a+1, ..., a+k-1, a+k+1, ..., a+n`. Therefore, only `a+k` is missing from the list (but of course, we don't know what that is yet!).

For a range of integers `a, a+1, ..., b` without any missing, the sum of them is `(a-b-1)(a+b)/2`. So all we need to do is to sum all of the integers in the *given* list, and subtract that sum from the `(a-b-1)(a+b)/2`, as:

```
def findMissing(l):
    n = len(l)
    if n == 0:
        return 0
    if n == 1:
        return l[0]
    # len(l) is >= 2
    a = min(l)
    b = max(l)
    fullSum = (b+1-a)*(a+b)//2
    sumInList = sum(l)
    return fullSum - sumInList

print(findMissing([10, 11, 13])) # prints 12
print(findMissing([1, 2, 3, 4, 5, 7, 8, 9, 10, 11])) # prints 6
print(findMissing([13, 11, 12, 9, 8])) # prints 10 (even though out of order)

```

We actually don't need to sort the list because all we need are the `max` and `min` of the array, which takes linear time instead of `n log(n)` time.

In fact, this does something even stronger: find the sum of *all* missing items from the list. Of course, if there is only 1 item missing, the number returned is the missing item.