ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 11 Weeks Ago, 5 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 12 May 2017 My Price 9.00

Write a program in python to compute if a given number

Write a program in python to compute if a given number is a valid credit card number.

Credit card numbers have what is called a check digit. This is a simple way of detecting common mis-typings of card numbers. The algorithm is as follows:

  1. Form a sum of every other digit, including the right-most digit; so 5490123456789128 sums to 8+1+8+6+4+2+0+4 = 33
  2. Form double each remaining digit, then sum all the digits that creates it; the remaining digits in our example (5 9 1 3 5 7 9 2) double to 10 18 2 6 10 14 18 4, which sums to 1+0+1+8+2+6+1+0+1+4+1+8+4 = 37
  3. Add the two sums above (33+37 = 70)
  4. If the result is a multiple of 10 (i.e., its last digit is 0) then it was a valid credit card number.

An example run might be:

Type a credit card number (just digits): 1
1 is not a valid credit card number

Another run might be:

Type a credit card number (just digits): 240
Yes, 240 is a valid credit card number

Another run might be:

Type a credit card number (just digits): 9548
Yes, 9548 is a valid credit card number

Another run might be:

Type a credit card number (just digits): 5490123456789129
5490123456789129 is not a valid credit card number

Answers

(11)
Status NEW Posted 12 May 2017 01:05 AM My Price 9.00

-----------

Not Rated(0)