'prefix' is the start of the CC number as a string, any number of digits.
    'length' is the length of the CC number to generate. Typically 13 or 16
183562
def completed_number(prefix, length):
    
    ccnumber = prefix
    # generate digits
    while len(ccnumber) < (length - 1):
        digit = random.choice(['0',  '1', '2', '3', '4', '5', '6', '7', '8', '9'])
        ccnumber.append(digit)
    # Calculate sum 
    sum = 0
    pos = 0
    reversedCCnumber = []
    reversedCCnumber.extend(ccnumber)
    reversedCCnumber.reverse()
    while pos < length - 1:
        odd = int( reversedCCnumber[pos] ) * 2
        if odd > 9:
            odd -= 9
        sum += odd
        if pos != (length - 2):
            sum += int( reversedCCnumber[pos+1] )
        pos += 2
    # Calculate check digit
    checkdigit = ((sum / 10 + 1) * 10 - sum) % 10
    ccnumber.append( str(int(checkdigit)) )
    return ''.join(ccnumber)
493626
def si_prefix(value):
    
    #standard si prefixes
    prefixes = ['y','z','a','f','p','n','u','m','','k','M','G','T','P','E','Z','Y']

    from math import log
    #closest 1000 exponent
    if value == 0: return (value, "")
    exp = int(log(value,1000)//1) + 8
    if exp < 0: exp = 0
    if exp > 16: exp = 16
    return (value*1000**(-(exp-8)), prefixes[exp])
854068
private int lengthOfTypePrefix(int type) {
        int length;
        switch (type) {
            case EmailRecipientUtils.BCC:
                length = 4;
                break;
            case EmailRecipientUtils.CC:
                length = 3;
                break;
            case EmailRecipientUtils.TO:
                length = 0;
                break;
            default:
                throw new IllegalArgumentException("Unknown type prefix: " + type);
        }
        return length;
    }
808035
def digits
      digitstring = ''
      [:area_code, :prefix, :number].each {|part|
        digitstring += self.send(part).to_s unless self.send(part).nil?
      }
      digitstring += " x#{extension}" unless extension.nil?
      digitstring
    end
1076510
def common_prefix(s1, s2):
    ""
    if not s1 or not s2:
        return ""
    k = 0
    while s1[k] == s2[k]:
        k = k + 1
        if k >= len(s1) or k >= len(s2):
            return s1[0:k]
    return s1[0:k]
650455
def length_prefix(length, offset):
    
    if length < 56:
        return chr(offset + length)
    else:
        length_string = int_to_big_endian(length)
        return chr(offset + 56 - 1 + len(length_string)) + length_string
871577
def credit_card_number(self, card_type=None):
        
        card = self._credit_card_type(card_type)
        prefix = self.random_element(card.prefixes)
        number = self._generate_number(self.numerify(prefix), card.length)
        return number
444936
static public function generateUniqidString($prefix = '', $length = 20)
    {
        $key = '';
        $keys = array_merge(range(0, 9), range('a', 'z'));

        for ($i = 0; $i < $length; $i++) {
            $key .= $keys[array_rand($keys)];
        }

        return uniqid($prefix) . $key;
    }
953491
function generateKey(length) {
    const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    const possibleLength = possible.length - 1;

    let text = '';
    _.times(getNumber(length, 16), () => {
        text += possible.charAt(_.random(possibleLength));
    });

    return text;
}
762014
def region_prefix(leading_zero = true)
      region_prefix = (rand(8) + 2).to_s + Faker.numerify( '#' * (rand(3) + 1) ).to_s
      region_prefix = '0' + region_prefix if leading_zero
      region_prefix
    end
303973
def lchop(string, prefix):
    
    if string.startswith(prefix):
        return string[len(prefix):]
    return string
198057
function pickPrefix(prefix, object) {
    var length = prefix.length;
    var sub;
    return foldl(
      function(acc, val, key) {
        if (key.substr(0, length) === prefix) {
          sub = key.substr(length);
          acc[sub] = val;
        }
        return acc;
      },
      {},
      object
    );
  }
1141813
def prefix(self, prefix):
        
        original_prefix = self._prefix
        self._prefix += prefix
        yield self
        self._prefix = original_prefix
140057
public String randomName(String prefix, int maxLen) {
        prefix = prefix.toLowerCase();
        int minRandomnessLength = 5;
        if (maxLen <= minRandomnessLength) {
            return randomString(maxLen);
        }

        if (maxLen < prefix.length() + minRandomnessLength) {
            return randomString(maxLen);
        }

        String minRandomString = String.format("%05d", Math.abs(RANDOM.nextInt() % 100000));

        if (maxLen <= prefix.length() + randName.length() + minRandomnessLength) {
            String str = prefix + minRandomString;
            return str + randomString((maxLen - str.length()) / 2);
        }

        String str = prefix + randName + minRandomString;
        return str + randomString((maxLen - str.length()) / 2);
    }
462478
def strnum(prefix: str, num: int, suffix: str = "") -> str:
    
    return "{}{}{}".format(prefix, num, suffix)
348071
function sequencer(prefix) {
  var curr = 1
  var max  = 0xFFFFFFFF

  if (prefix) {
    prefix = "" + prefix
  }
  else {
    prefix = ""
  }

  return getNext

  //-----------------------------------
  function getNext() {
    var result = curr

    curr++
    if (curr >= max) curr = 0

    return prefix + result
  }
}
1328851
function lengthOfNumber(number) {
        if (isNumber(number)) {
            var length_1 = 0;
            while (number > 0) {
                length_1++;
                number = backIntegerOfNumber(number / 10);
            }
            return length_1;
        }
        else {
            return 0;
        }
    }