Skip to content

Instantly share code, notes, and snippets.

Avatar

Li Yao lastland

View GitHub Profile
@unionx
unionx / iter.lisp
Created Jul 21, 2012
Iteration in Common Lisp
View iter.lisp
;;;;;; iteration in common lisp
;;;; do
;; `do` is like `if` in c
(do ((x 1 (+ x 1))
(y 1 (* y 2)))
((> x 5) y) ;; when x is bigger than 5, return y
(print y)
@stribika
stribika / montgomery_ladder.py
Created Feb 14, 2016
Basic Montgomery ladder implementation. In the test it works with just numbers, but you can plug in any operation.
View montgomery_ladder.py
#!/usr/bin/python3 -O
from math import floor, log
def montgomery_ladder(x, n, op, select):
k = floor(log(n, 2)) + 1
x1 = x
x2 = op(x, x)
for i in range(k - 2, -1, -1):
bit = 1 if n & (1 << i) else 0
You can’t perform that action at this time.