Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 916315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:02:00+00:00 2026-05-15T18:02:00+00:00

these two algorithms are used to check valid member numbers the first is the

  • 0

these two algorithms are used to check valid member numbers
the first is the one I was given by the company,
the second is one I devised, from my tests I can’t see any difference between them functionally,

are there any cases anyone can see where they would return different outputs?

test input: 
6014355021355010
or
6014355065446212
or
6014351000254605

The check digit is calculated using the first 15 digits as follows:

  1. Sum the digits in the even numbered positions from left to right
  2. Multiply each digit in the odd numbered positions (from left to
    right) by the number 2. If any results
    are 2 digits, sum the digits into one.
    Sum the digits from each
    multiplication into a final result.
  3. Add the final results of steps 1 and 2.
  4. Take the last digit of the result from step 3 and subtract from 10 to
    give the check digit.
  5. Take the last digit from the 16 Digit number and compare to the check digit
  6. if they are equal, it is valid

vs

The check digit is calulated using the whole 16 digits as follows:

  1. Sum the digits in the even numbered positions from left to right
  2. Multiply each digit in the odd numbered positions (from left to
    right) by the number 2. If any results
    are 2 digits, sum the digits into one.
    Sum the digits from each
    multiplication into a final result.
  3. Add the final results of steps 1 and 2.
  4. Take the final result and Modulus 10
  5. If the result is 0, it is valid

Update:
ok so. I have tried to create both these algorithms in php,
the second one, i have created successfully,
the first however, i can not seem to get to work.

possibly i have read this wrong, but, here is the original brief i was given for the first algorithm:

16 digit number modulus 10 check digit calculation

The check digit is calculated using the first 15 digits as follows:
1. Sum the digits in the even numbered positions from left to right

2. Multiply each digit in the odd numbered positions (from left to right) by the number 2
If any results are 2 digits, sum the digits into one.
Sum the digits from each multiplication into a final result.

3. Add the final results of steps 1 and 2.

4. Take the last digit of the result from step 3 and subtract from 10 to give the check digit.
If the result of step 3 is a multiple of 10, then the check digit will be zero.


Example 6014 3590 0000 0928
1.0 0 + 4 + 5 + 0 + 0 + 0 + 9 = 18
2.0 6 * 2 = 12 so 1 + 2 = 3
2.1 1 * 2 = 2
2.2 3 * 2 = 6
2.3 9 * 2 = 18 so 1 + 8 = 9
2.4 0 * 2 = 0
2.5 0 * 2 = 0
2.6 0 * 2 = 0
2.7 2 * 2 = 4
2.8 3 + 2 + 6 + 9 + 0 + 0 + 0 + 4 = 24
3.0 18 + 24 = 42
4.0 The check digit is 10 – 2 = 8
5.0 8 = the 16th digit (601435900000092[8])


Update2:
ok, so i have corrected the algorithm,

also, i should mention, that there are two other checks
if(length of number != 16)
return 1;
and
if(first 5 characters != 601435)
return 1;

so are there any counters to this?

cheers,
Matt


Algorithm test [php]

<?php
$file = file_get_contents('fb.csv');
$numbers = explode("\n", $file);

function validate_flybuys($number) {
    $r = array ('o' => '0', 'i' => '1', 'l' => '1', 'e' => '3', ' ' => '');
    $flybuys = trim(strtolower($number));
    $flybuys = str_replace(array_keys($r), $r, $flybuys);
    if('601435' != substr($flybuys, 0, 6) || strlen($flybuys) != 16)
            return 1;
    $evens = 0;
    $odds = '';

    for($i = 0; $i <= 15; $i+=2) {
        $odds .= $flybuys[$i];
        $evens += $flybuys[$i+1];
    }

    $odds = str_split($odds);
    foreach($odds as &$odd) {
        $odd = $odd*2;
        if($odd >= 10) {
            $odd = str_split($odd);
            $odd = $odd[0] + $odd[1];
        }
    }
    return (array_sum($odds)+$evens) % 10;
}

function validate_flybuys2($number) {
    $r = array ('o' => '0', 'i' => '1', 'l' => '1', 'e' => '3', ' ' => '');
    $flybuys = trim(strtolower($number));
    $flybuys = str_replace(array_keys($r), $r, $flybuys);
    if('601435' != substr($flybuys, 0, 6) || strlen($flybuys) != 16)
            return 1;
    $evens = 0;
    $odds = '';

    for($i = 0; $i <= 14; $i+=2) {
        $odds .= $flybuys[$i];
        if($i != 14)
            $evens += $flybuys[$i+1];
    }

    $odds = str_split($odds);
    foreach($odds as &$odd) {
        $odd = $odd*2;
        if($odd >= 10) {
            $odd = str_split($odd);
            $odd = $odd[0] + $odd[1];
        }
    }
    $total = (array_sum($odds))+$evens;
    $total = str_split($total);
    $check = 10 - $total[1];
    $check = $check % 10;
    if($check == substr($flybuys, 15, 1))
        return 0;
    else
        return $check;
}

foreach($numbers as $number) {
    $valid = validate_flybuys($number);
    $valid2 = validate_flybuys2($number);
    if($valid != $valid2 || $valid != 0) {
        echo '<hr />';
        echo 'NUMBER: '.$number.'<br />';
        echo 'V1: '.$valid.'<br />';
        echo 'V2: '.$valid2.'<br />';
    }
}

if anyone is interested and comments i can post some sample numbers to test against 🙂
oh and feel free to optimize the code 8D

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:02:01+00:00Added an answer on May 15, 2026 at 6:02 pm

    EDIT: This proof only works if the step 5 and 6 of the first algorithm are an equal check instead of a modulus calculation. The equal check seems to be meant by the original brief as mentioned in the comments.

    EDIT2: I think the first algorithm should look like this. But you should better verify this, maybe from the one who gave you the original brief.

    1. Sum the digits in the even numbered positions from left to right
    2. Multiply each digit in the odd numbered positions (from left to right) by the number 2. If any results are 2 digits, sum the digits into one. Sum the digits from each multiplication into a final result.
    3. Add the final results of steps 1 and 2.
    4. Take the last digit of the result from step 3 and substract from 10 to give the check digit.
    5. Take the last digit of the 16digit-number and if it is the same as the computed check digit the number is valid

    To verifiy mathematically that both algorithms are equal you can use congruency.

    Let’s say a is the sum from step 3 of the first algorithm, b is the sum of step 3 of the second algorithm and c is the 16th digit (the check digit).

    Than the difference between a and b is that c is added to b but not to a, which means:

    a ≡ b - c mod 10
    

    The check from the first algorithm is performed by substracting a from 10 and check if it is congruent c for modulus 10. (for addition and substraction it doesn’t matter when the modulus is performed)

    10 - a ≡ c mod 10
    

    this is equal to:

    -a ≡ c mod 10
    

    Now you can substitute a with the first one, which results in

    -(b - c) ≡ c mod 10
    

    this is equal to:

    c - b ≡ c mod 10
    

    and this is equal to:

    -b ≡ 0 mod 10
    b ≡ 0 mod 10
    

    and that is the check, which is performed in the second algorithm. So both algorithms returns the same result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

These two methods exhibit repetition: public static Expression<Func<Foo, FooEditDto>> EditDtoSelector() { return f =>
These two may look like they have no correlation but bear with me! In
Consider these two function definitions: void foo() { } void foo(void) { } Is
Do these two keywords have exactly the same effect, or is there something I
Notice these two RedHat Linux system configuration settings: $ getconf GNU_LIBC_VERSION glibc 2.3.4 $
Are these two terms interchangeable?
Can these two SVN clients collaborate? I have my projects checked out with Tortoise,
There is a standard two-pass algorithm mentioned in RFC 1942: http://www.ietf.org/rfc/rfc1942.txt however I haven't
Is there an algorithm for accurately multiplying two arbitrarily long integers together? The language
Is there a fast algorithm for finding the Largest Common Substring in two strings

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.