我无法在C的while循环中找出一些错误。解决cs50积分中的问题:卢恩算法

我试图找出在CS50信用问题的第一步中做错了什么。我正在尝试创建一个实现Luhn算法的程序。我已经弄清楚了如何从最低有效位开始添加其他所有数字。但是我有一个问题,就是将其他两位数字乘以2,然后将乘积的数字分别相加。我最初决定做一个数组,但是由于有人建议可以通过循环解决,所以我现在尝试做一个while循环。当我输入贷方编号4003600000000014时,它返回的值是24而不是13。我无法弄清逻辑错误,并且我已经尝试解决了几个小时。一定会感谢您的帮助!

#include <stdio.h>
#include <cs50.h>

int sum_digits(int number2);
int get_number_digits(long x);
int times_two(int x);

int main(void) {
  
  //Prompt for input
  long number = get_long("Card Number: \n");
  //initialize number to two different variables for [1. multiplying by
  //2, adding the products]
  //[2. adding every other digit]
  long number2 = number;
  long number3 = number;
  
  //Calculate checksum
  
  //Multiply digits by 2 alternately starting from the tens place, then
  //add the digit of the products NOTE: edit loop, something is wrong
  long remainderr2, currentnumber2, product, initialsum, finalfinalsum;
  currentnumber2 = number3 / 10;
  number3 = currentnumber2;
  
  int finalsum = 0;
  while (number3 > 0) {
    
    number3 = currentnumber2;
    remainderr2 = currentnumber2 % 10;
    product = times_two(remainderr2);
    initialsum = sum_digits(product);
    finalfinalsum = 0 + finalsum;
    finalsum = finalsum + initialsum;
    currentnumber2 = currentnumber2 / 10;
    currentnumber2 = currentnumber2 / 10;
  }
  printf("%ld", finalfinalsum);
}

//Function that adds the digits of a number
int sum_digits(int number2) {
  int secondstep, remainderr, currentnumber, sum;
  currentnumber = number2;
  secondstep = 0;
  while (number2 > 0) {
    number2 = currentnumber;
    sum = 0 + secondstep;
    remainderr = currentnumber % 10;
    secondstep = sum + remainderr;
    currentnumber = number2 / 10;
    
  }
  return sum;
  
}

//Function that multiplies int by 2
int times_two(int x) {
  x = x * 2;
  return x;
}