Skip to content

Instantly share code, notes, and snippets.

Li Yao lastland

Block or report user

Report or block lastland

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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
@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)
You can’t perform that action at this time.