Skip to content

Instantly share code, notes, and snippets.

View Carleslc's full-sized avatar

Carlos Lázaro Costa Carleslc

View GitHub Profile
@Carleslc
Carleslc / passwordGenerator.lua
Last active October 5, 2018 23:21
SimplePasswordGenerator created by Carleslc - https://repl.it/@Carleslc/SimplePasswordGenerator
function randPW(length, strong)
local index, pw, rnd = 0, ""
local chars = {
"ABCDEFGHIJKLMNPQRSTUVWXYZ", -- O
"abcdefghijklmnopqrstuvwxyz",
"123456789" -- 0
}
if strong then
table.insert(chars, "!\\#$%&()*+,-./:;<=>?@[]^_{|}~") -- '"
end
@Carleslc
Carleslc / factorial.kt
Created March 15, 2018 03:56
Factorial in Kotlin
/** If high-performance is needed consider using Guava BigIntegerMath.factorial instead **/
fun Long.factorial(): BigInteger {
fun factorial(start: Long, n: Long): BigInteger {
var i: Long
if (n <= 16) {
var r = BigInteger.valueOf(start)
i = start + 1
while (i < start + n) {
r = r.multiply(BigInteger.valueOf(i))
i++