Skip to content

GTIN 8, 12, 13, 14 #13

Description

@martinusso
            var sum = 0;
            var multiply = false;
            foreach (var c in s.ToCharArray()) 
            {
                var n = int.Parse(c.ToString());
                sum += multiply ? (n*3) : n;
                multiply = !multiply;
            }  
            var mod = (sum % 10);
            if (mod == 0)
                return 0;
            return 10 - mod;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions