[Solved] C Programming: How do I insert a number into an array such that each digit of the number goes into each field of the array? [closed]

#include <stdio.h> #define MAX_NUMS 5 // change me to 1000 int main(int argc, const char * argv[]) { char numberString[ MAX_NUMS + 1 ]; int numberNumeric [ MAX_NUMS ]; printf(“Enter number “); scanf(“%s”,numberString); for ( int i=0; i < MAX_NUMS; ++i) { printf(“converting %c\n”,numberString[i]); numberNumeric[i] = (numberString[i] – 0x30); // convert ascii to integer } … Read more

[Solved] Summing the digits of a very large number [closed]

This would be a complete implementation in Haskell import Data.List.Split (chunksOf) import Data.List import Data.Char (digitToInt) main :: IO () main = do digits <- map digitToInt <$> readFile “pifile.txt” let summator = foldl1′ (zipWith (+)) . chunksOf 4 print $ summator digits I will update this with some explanation later this day. Update @Comments … Read more

[Solved] Int64 arithmetic error

Statement (long)0.75 will return 0 (converting double to long will take greatest integer value, that is lower that converting double). So you have 0 * 9223372036854775807 which is hopefully 0. By the way long is alias for Int64, which means they are the same underlying types, so by (long)Int64.MaxValue you casting long to long to … Read more

[Solved] Finding solutions for a given pair (number of factors, number of prime factors)

Let p1, p2, p3, … pk be the prime factors of some positive integer n. By the fundamental theorem of arithmetic, n can be represented as p1e1•p2e2•p3e3• … pkek for some positive integers e1, e2, e3, … ek. Furthermore, any such set of such positive integers represents one positive integer in this way. Every factor … Read more