Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 103
See the difference (BigInt in C++ and Python)
Rei: To clarify on OP's behalf: Python supports int values of arbitrary size, C++ does not. This is because Python focuses on achieving results quickly, while C++ primes in runtime performance, letting you decide the optimal structure to deal with BigInt. This thread is not an attack on C++. There are also well-written, ready-to-use C++ BigInt libraries online, e.g. https://github.com/sercantutar/infint https://code.sololearn.com/caP8649IZ2fH/?ref=app https://code.sololearn.com/cQKjPRAb6JcZ/?ref=app
60 Respostas
+ 24
Congratulations, you made me write code.
https://code.sololearn.com/cqtn357OfStn/?ref=app
+ 118
Sorry, but your C++ code is just overkill. You can do the same calculation in C++ with only 1 line of code and thereby reach a sufficient precision, too:
https://code.sololearn.com/c81HCw3Wbohj/#cpp
+ 64
In programmer performance, Python is superior. In runtime performance C++ is superior.
So the tool of choice for code that only needs to run occasionally is Python. When code needs to run often or runs on a battery powered device, you might want to consider C++.
+ 30
Yes, you can easily calculate 40 numbers more. That's because Python doesn't have a native variable limit like C++ does. The limit has a reason though. C++ and Python are different languages with different strenghts used for different purposes, so there's no point in badmouthing a language because of something it wasn't built for. Such integer precision doesn't have any practical use in C++ applications and I can assure you that nobody read past the 10th number. You will never write 60 lines to get some extra precision in a calculation and you'll still get a good enough result.
Furthermore, C++ calculates 94 Fibonacci numbers way faster than Python does.
I see your point, but your statement is very misleading.
+ 28
Chris
totally my post has joking aspect , i want show a small limit can make the code too long
And about function , it's very simple , i will write how it works in next few days
+ 23
Chris
& another thing
It's not just 30 line code to calculate 40 another numbers that as you said nobody cares about that
It's good training for beginners and for my future project š
+ 23
Hatsy Rei
awesome š
+ 22
wd00009
thank you šā¤
+ 20
The thing is, you're nowhere explicitely telling that your statement is about the length of the numbers you're calculating.
You're linking two codes called "Fibonacci series", saying that the C++ one is 60 times longer, and that's it. There's no mention about a joking aspect or what you are actually trying to achieve here.
Yes, it's good training. But you're implicitely making people think that Python is superior by giving a false positive example.
+ 18
Naman
just read the comments in this post to understand why this contain 64 line
+ 18
Costin Onciu
anyway C has limit for variables
even if using array or not
+ 18
Freddy
awesome idea but how can convert string to number ?! š¤
+ 17
Fistefalo
ŃŠµŃŠøŃ ŃŠøŃŠµŠ», Š² ŠŗŠ¾ŃŠ¾ŃŃŃ
ŠŗŠ°Š¶Š“Š¾Šµ ŃŠøŃŠ»Š¾ (ŃŠøŃŠ»Š¾ Š¤ŠøŠ±Š¾Š½Š°ŃŃŠø) ŃŠ²Š»ŃŠµŃŃŃ ŃŃŠ¼Š¼Š¾Š¹ Š“Š²ŃŃ
ŠæŃŠµŠ“ŃŠ“ŃŃŠøŃ
ŃŠøŃŠµŠ». ŠŃŠ¾ŃŃŠµŠ¹ŃŠøŠ¼ ŃŠ²Š»ŃŠµŃŃŃ ŃŃŠ“ 1, 1, 2, 3, 5, 8,
+ 17
phyton vs c++ is amazing coder its so wow magic
+ 16
Chris
you forgot one thing ,
that my code can calculate fibonacci series up to 141th number (not 94th as you wrote),
i wrote 30 rows code to break that limit broš
#look_carefully #eyes_wide_shut
goodluck
+ 16
Fistefalo
Š“Š°, Ń Š“ŠµŠ»Š°Ń ŃŠ¾Ń Š¶Šµ ŠŗŠ¾Š“, Š½Š¾, Šŗ ŃŠ¾Š¶Š°Š»ŠµŠ½ŠøŃ, Š² c ++, ŠæŠ¾ŃŠŗŠ¾Š»ŃŠŗŃ Š²Ń Š·Š½Š°ŠµŃŠµ, ŃŃŠ¾ Ń Š½Š°Ń ŠµŃŃŃ Š¾Š³ŃŠ°Š½ŠøŃŠµŠ½ŠøŠµ ŠæŠµŃŠµŠ¼ŠµŠ½Š½Š¾Š¹, ŠŗŠ¾ŃŠ¾ŃŠ¾Šµ Š½Šµ Š¼Š¾Š¶ŠµŃ Ń
ŃŠ°Š½ŠøŃŃ Š²ŠµŃŃ
Š½ŠøŠµ Š·Š½Š°ŃŠµŠ½ŠøŃ 18 * (10 ^ 18), ŠæŠ¾ŃŃŠ¾Š¼Ń Ń Š½Š°ŠæŠøŃŠ°Š» ŃŠ»ŠøŃŠŗŠ¾Š¼ Š“Š»ŠøŠ½Š½ŃŠ¹ ŠŗŠ¾Š“, ŃŃŠ¾Š±Ń ŃŠ°Š·Š±ŠøŃŃ ŃŃŠ¾Ń ŠæŃŠµŠ“ŠµŠ» Šø Š²ŃŃŠøŃŠ»ŠøŃŃ 141-Šµ ŃŠøŃŠ»Š¾ ŃŠøŠ±Š¾Š½Š°ŃŃŠø Ń 30 ŃŠøŃŃ ŃŠµŠ»ŃŃ
ŃŠøŃŠµŠ» :)
+ 14
OMG
i should learn phython soon.
+ 13
Fistefalo
Ń Š½Šµ ŠæŠ¾Š½ŠøŠ¼Š°Ń, ŃŃŠ¾ Š²Ń ŠøŠ¼ŠµŠµŃŠµ Š² Š²ŠøŠ“Ń !
+ 12
You could also write READABLE python programmes
https://code.sololearn.com/cn5faURSpwLi/?ref=app
+ 10
this doesn't contain 64 lines
https://code.sololearn.com/cyn8jnfcr9pW/?ref=app