Looping up to 600 billion will take forever — not just a long time, but impossible because it exceeds what can be stored in an int
(usually up to 2^31-1 these days, but could be as small as 2^15-1 according to the C standard).
What you need is a smarter algorithm. Rather than giving you the solution verbatim, I suggest that you look at existing answers and work out a solution in C by yourself.
Related Contents:
- How to initialize all members of an array to the same value?
- Improve INSERT-per-second performance of SQLite
- Why should we typedef a struct so often in C?
- Overloading Macro on Number of Arguments
- Read .csv file in C
- How to prevent SIGPIPEs (or handle them properly)
- How do I create an array of strings in C?
- Pointer to pointer of structs indexing out of bounds(?) when I try to index anything other than zero
- Does stack grow upward or downward?
- Is unsigned integer subtraction defined behavior?
- Catch and compute overflow during multiplication of two large integers
- Syntax and Sample Usage of _Generic in C11
- Rounding integer division (instead of truncating)
- Connecting n commands with pipes in a shell?
- what’s the differences between r and rb in fopen
- Combine Gyroscope and Accelerometer Data
- How to use pointer expressions to access elements of a two-dimensional array in C?
- How to initialize array to 0 in C?
- Threadsafe vs re-entrant
- How to use netlink socket to communicate with a kernel module?
- GCC with -std=c99 complains about not knowing struct timespec
- String literals vs array of char when initializing a pointer
- How to printf a memory address in C
- What does ‘sizeof (function name)’ return?
- How to make a char string from a C macro’s value?
- Converting an int into a 4 byte char array (C)
- Do threads have a distinct heap?
- Writing binary number system in C code [duplicate]
- Is NULL always false?
- Is un-initialized integer always default to 0 in c?
- How to use #if inside #define in the C preprocessor?
- Does C99 guarantee that arrays are contiguous?
- Header per source file
- Fastest Implementation of the Natural Exponential Function Using SSE
- Indenting #defines
- What is “…” in switch-case in C code
- Determining sprintf buffer size – what’s the standard?
- Passing a matrix in a function (C)
- How can I access a graphics card’s output directly?
- Is it possible to store the address of a label in a variable and use goto to jump to it?
- C equivalent to fstream’s peek
- Passing arrays and matrices to functions as pointers and pointers to pointers in C
- printf insufficient arguments
- What are the implications of the linux __user macro?
- Is calloc(4, 6) the same as calloc(6, 4)?
- Dynamic method dispatching in C
- Algorithm to find all the exact divisors of a given integer
- Compiling multiple C files in a program
- Is it optional to use struct keyword before declaring a structure object?
- How to set up a cron job to run an executable every hour?