fork download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. //Storing the 1000 digits
  4. char number_array[] =
  5. "73167176531330624919225119674426574742355349194934"
  6. "96983520312774506326239578318016984801869478851843"
  7. "85861560789112949495459501737958331952853208805511"
  8. "12540698747158523863050715693290963295227443043557"
  9. "66896648950445244523161731856403098711121722383113"
  10. "62229893423380308135336276614282806444486645238749"
  11. "30358907296290491560440772390713810515859307960866"
  12. "70172427121883998797908792274921901699720888093776"
  13. "65727333001053367881220235421809751254540594752243"
  14. "52584907711670556013604839586446706324415722155397"
  15. "53697817977846174064955149290862569321978468622482"
  16. "83972241375657056057490261407972968652414535100474"
  17. "82166370484403199890008895243450658541227588666881"
  18. "16427171479924442928230863465674813919123162824586"
  19. "17866458359124566529476545682848912883142607690042"
  20. "24219022671055626321111109370544217506941658960408"
  21. "07198403850962455444362981230987879927244284909188"
  22. "84580156166097919133875499200524063689912560717606"
  23. "05886116467109405077541002256983155200055935729725"
  24. "71636269561882670428252483600823257530420752963450";
  25.  
  26. #include <inttypes.h>
  27.  
  28. int main(void){
  29. int length = sizeof(number_array);
  30. long long max_product = 0;
  31. int i, j;
  32.  
  33. for( i = 0; i <= length - 13; i++){
  34.  
  35. long long product = 1;
  36.  
  37. //Going through 13 consecutive digits for each digit in the char array
  38. for(j = 0; j < 13; j++){
  39. // printf("product -- > %d and number -- > %d\n",product ,(number_array[i+j] - 0x30));
  40.  
  41. // finding the product
  42. product = product * (number_array[i + j] - 0x30);
  43.  
  44. //if product is zero skipping the process
  45. if(product == 0){break;}
  46. }
  47.  
  48. // printf("product -- > %I64d\n", product);
  49.  
  50. //checking for the max product
  51. if(product > max_product){
  52. max_product = product;
  53. }
  54.  
  55. }
  56.  
  57. printf("max_product -- > %lld\n", max_product);
  58. }
  59.  
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
max_product -- > 23514624000