Skip to content

Instantly share code, notes, and snippets.

@Keirua
Keirua / fib_log.py
Created Apr 13, 2020
fibonacci with O(log(n)) complexity
View fib_log.py
#
from decimal import *
def fib(n):
return fib_iter(1,0,0,1,Decimal(n))
def fib_iter(a,b,p,q,n):
nb_iter = 0
while n != 0:
@Keirua
Keirua / use-array_key_exists.php
Created Dec 13, 2016
Utilisez array_key_exists !
View use-array_key_exists.php
<?php
$a = ['AB' => 12, 'CB' => 34];
echo "Cas nominal : La clé est présente dans le tableau".PHP_EOL;
echo (int)array_key_exists('AB', $a).PHP_EOL;
echo (int)isset($a['AB']).PHP_EOL;
echo (int)!empty($a['AB']).PHP_EOL;
echo "Cas nominal : La clé n'est pas présente dans le tableau".PHP_EOL;
You can’t perform that action at this time.