Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In Python

  >>> (-80538738812075974)**3 + 80435758145817515**3 + 12602123297335631**3
  42


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.


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.


In bash

  $ echo "print((-80538738812075974)^3 + 80435758145817515^3 + 12602123297335631^3)" | sed "s/\^/**/g" | python -
  42


You're just using python, using bc is more bashy:

    $ echo '(-80538738812075974)^3 + 80435758145817515^3 + 12602123297335631^3' | bc
    42


Without shelling out:

  $ echo $(((-80538738812075974)**3 + 80435758145817515**3 + 12602123297335631**3))
  42


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.


One more proof that you can do everything in bash.


In dc/shell/bash

       dc -e '_80538738812075974 3 ^ 80435758145817515 3 ^ 12602123297335631 3 ^ + + p'


In SQL: SELECT (-80538738812075974::NUMERIC)^3 + 80435758145817515::NUMERIC^3 + 12602123297335631::NUMERIC^3;


Javascript in FF/Chrome:

    > (-80538738812075974n)**3n + 80435758145817515n**3n + 12602123297335631n**3n
    42n
https://caniuse.com/#search=bigint


In Scala:

  scala> BigInt("-80538738812075974").pow(3) + BigInt("80435758145817515").pow(3) + BigInt("12602123297335631").pow(3)
  res0: scala.math.BigInt = 42


In Pharo

  (-80538738812075974 raisedTo: 3)
 + (80435758145817515 raisedTo: 3)
 + (12602123297335631 raisedTo: 3)  "42"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: