From 9a5f918d76c57dfa14555abb541dd3069da0ef45 Mon Sep 17 00:00:00 2001 From: remy Date: Sat, 25 Apr 2020 14:15:47 +0200 Subject: [PATCH] tablespace --- src/main.cr | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/main.cr b/src/main.cr index d69bd3c..637fbdc 100644 --- a/src/main.cr +++ b/src/main.cr @@ -27,17 +27,16 @@ def is_valid_isbn(isbn_code) pp "check_digit_isbn10" i = check = 0 t = 10 - while i < 9 - check = array[i].to_i * (t - i) + check - i = i + 1 - end + while i < 9 + check = array[i].to_i * (t - i) + check + i = i + 1 + end pp result = ( 11 - (check % 11)) % 11 if (result - array[9].to_i) == 0 - pp "isbn10 is ok" - else - pp "isbn10 check key fail" - end - + pp "isbn10 is ok" + else + pp "isbn10 check key fail" + end elsif isbn_code.size ==13 pp "isbn13" pp "check_digit_isbn13" @@ -52,10 +51,10 @@ def is_valid_isbn(isbn_code) end pp result = 10 - (check % 10) if result - array[12].to_i == 0 - pp "isbn13 is ok" - else - pp "isbn13 check key fail" - end + pp "isbn13 is ok" + else + pp "isbn13 check key fail" + end else pp "wrong size" return false @@ -64,7 +63,6 @@ def is_valid_isbn(isbn_code) pp "ko not only number" return false end - end