Why does this stop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Why does this stop

why does the pattern change when it exceeds 1 billion? https://code.sololearn.com/cEPfPq4AN5wg/?ref=app

17th Apr 2018, 2:41 PM
Jaafer Hazim
Jaafer Hazim - avatar
4 Answers
+ 5
Your integer simply can't store higher numbers. You could use unsigned long long or uint64_t + stdint.h header to get the largest possible int value (64bit => 2^64)
17th Apr 2018, 2:49 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 6
You've exceeded the maximum number for a long int. You can try an unsigned long long to increase this range. Edit: Dang, Aaron beat me to it. Or, you can use a string and add '0' to the end of it each time. Here is an example with strings: https://code.sololearn.com/cP1SJEIXKtNb/?ref=app
17th Apr 2018, 2:53 PM
Rrestoring faith
Rrestoring faith - avatar
+ 3
Aaron Eberhardt thanks❤
17th Apr 2018, 2:51 PM
Jaafer Hazim
Jaafer Hazim - avatar
+ 3
Rrestoring faith nice idea👌.. thanks❤
17th Apr 2018, 2:55 PM
Jaafer Hazim
Jaafer Hazim - avatar