// Perform the double alternate algorithm and return
// the remainder of the operation
func DoubleAlternate(b m.BankAccount, data m.SortCodeData, sum int) (remainder int) {
	numbers := b.MergeAccountDetails()

	weights := data.Weights
	for i, nb := range numbers {
		sum += helpers.AddDigits(weights[i] * nb)
	}

	remainder = sum % 10

	return
}
示例#2
0
// Perform the modulus algorithm with a given modulus
// and return the remainder of the operation
func Modulus(b m.BankAccount, modulus int, data m.SortCodeData) (remainder int) {
	numbers := b.MergeAccountDetails()
	sum := 0
	weights := data.Weights

	for i, nb := range numbers {
		sum += weights[i] * nb
	}

	remainder = sum % modulus

	return
}