Re:42 is found to be the sum of three cubes
by petrikapu on Friday September 06, 2019 @10:39AM
(#20896028)
In Python
[ Parent
| on HN ]
Re:42 is found to be the sum of three cubes
by stefan_ on Friday September 06, 2019 @12:15PM
(#20896941)
In Google:
1.9892987e+35
It pains me how its 2019 and the fricking Google calculator is less powerful than a solar powered credit-card sized one from the 90s. A single chip made on the earliest imaginable IC processes can effortlessly deal with larger numbers than the lazy ignorant Google implementation. Maybe they can make this an interview question.
Re:42 is found to be the sum of three cubes
by abdulhaq on Friday September 06, 2019 @04:17PM
(#20899506)
Most calculators of that era had a maximum number
Of digits between 8 and 12. Perhaps the Hp48 could do this calculation but not any of the credit card calcs.
Re:42 is found to be the sum of three cubes
by antoineMoPa on Friday September 06, 2019 @10:54AM
(#20896186)
In bash
$ echo "print((-80538738812075974)^3 + 80435758145817515^3 + 12602123297335631^3)" | sed "s/\^/**/g" | python -
42
Re:42 is found to be the sum of three cubes
by Franciscouzo on Friday September 06, 2019 @12:01PM
(#20896830)
You're just using python, using bc is more bashy:
$ echo '(-80538738812075974)^3 + 80435758145817515^3 + 12602123297335631^3' | bc
42
Re:42 is found to be the sum of three cubes
by saagarjha on Friday September 06, 2019 @11:57AM
(#20896793)
Without shelling out:
$ echo $(((-80538738812075974)**3 + 80435758145817515**3 + 12602123297335631**3))
42
Re:42 is found to be the sum of three cubes
by hazeii on Friday September 06, 2019 @11:03AM
(#20896258)
In calc:
$ calc
calc 2.12.4.1
> (-80538738812075974)^3 + 80435758145817515^3 + 12602123297335631^3
42
>Literally pasted off the web page and verified in a couple of seconds.
Re:42 is found to be the sum of three cubes
by wruza on Friday September 06, 2019 @11:53AM
(#20896750)
One more proof that you can do everything in bash.
Re:42 is found to be the sum of three cubes
by zests on Friday September 06, 2019 @10:59AM
(#20896226)
In dc/shell/bash
dc -e '_80538738812075974 3 ^ 80435758145817515 3 ^ 12602123297335631 3 ^ + + p'
Re:42 is found to be the sum of three cubes
by taneliv on Friday September 06, 2019 @11:06AM
(#20896285)
In SQL: SELECT (-80538738812075974::NUMERIC)^3 + 80435758145817515::NUMERIC^3 + 12602123297335631::NUMERIC^3;
Re:42 is found to be the sum of three cubes
by xhroot on Friday September 06, 2019 @11:20AM
(#20896424)
Javascript in FF/Chrome:
> (-80538738812075974n)**3n + 80435758145817515n**3n + 12602123297335631n**3n
42n
https://caniuse.com/#search=bigint
Re:42 is found to be the sum of three cubes
by harryh on Friday September 06, 2019 @11:10AM
(#20896320)
In Scala:
scala> BigInt("-80538738812075974").pow(3) + BigInt("80435758145817515").pow(3) + BigInt("12602123297335631").pow(3)
res0: scala.math.BigInt = 42
Re:42 is found to be the sum of three cubes
by Fuhrmanator on Sunday September 08, 2019 @10:58AM
(#20910917)
In Pharo
(-80538738812075974 raisedTo: 3)
+ (80435758145817515 raisedTo: 3)
+ (12602123297335631 raisedTo: 3) "42"