Ad
  • Custom User Avatar

    It shouldn't work with floats. If floats ar needed return must be changed from int to float

  • Custom User Avatar

    I can't get it:

    //1..9 = (9 * 1) = 9

    //10..99 = (100 * 2) = 200

    //100..999 = (1_000 * 3) = 3_000

    //1000..9999 = (10_000 * 4) = 40_000

    //10_000..99_999 = (100_000 * 5) = 500_000

    //100_000..999_999 = (1_000_000 * 4) = 6_000_000

    //1_000_000..9_999_999 = (10_000_000 * 7) = 70_000_000

    //10_000_000..36_123_011 = (26123011 * 8) = 208_984_088

    //sum: 208_984_088 + 70_000_000 + 6_000_000 + 500_000 + 40_000 + 3_000 + 200 + 9 = 285_527_297

    //And solution is telling 277_872_985

    What am I doing wrong?

  • Custom User Avatar

    If you have set declare(strict_types=1); php would throw an error (because you try to return string as int), if this declaration is missing it will convert string to int.

  • Custom User Avatar

    I've changed assert types, should be fine now, thanks

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution