Skip to content

Instantly share code, notes, and snippets.

View ab99484's full-sized avatar

AB ab99484

  • Germany
View GitHub Profile
@ab99484
ab99484 / calcChecksum.rb
Created November 5, 2018 20:55 — forked from trdev7/calcChecksum.rb
This Ruby file includes Ruby functions that Luhn algorithm is implemented. checkLuhn1 returns value if current barcode(including check digit) validates. checkLuhn2 returns value that current barcode join its checkdigit as suffix.
def sumLuhn (barcode, nParity)
checksum = 0
for i in 0..barcode.length - 1
nDigit = barcode[i].to_i
if nParity == i % 2
nDigit = nDigit * 2
end
checksum = checksum + nDigit / 10 + nDigit % 10
end
return checksum % 10
@ab99484
ab99484 / division_bignumber.c
Created November 5, 2018 20:55 — forked from trdev7/division_bignumber.c
This application is C console application that substraction, division and remainder between two bigNumbers is implemented.
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef signed short int_least16_t;
// swapping two charaters
void swap( char* a, char* b ) {
char p = *a;
*a = *b;