• Hotzilla@sopuli.xyz
    link
    fedilink
    arrow-up
    1
    ·
    6 months ago

    Could be easily made 50% space saving by only iffin all odds and return even on else. Maybe one if before to handle overflow to avoid wrong even if over the last if.

    • bjorney@lemmy.ca
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      6 months ago

      Yeah but then ALL even numbers would be slow to compute because you would have to chain through every odd before you know that 2 is even.

      Depends on the expected distribution of input values

    • Th4tGuyII@kbin.social
      link
      fedilink
      arrow-up
      1
      ·
      6 months ago

      There’s not a single thing in this universe that cannot be accomplished with enough IF statements… as long as you’ve got infinite time to wait

  • merc@sh.itjust.works
    link
    fedilink
    arrow-up
    1
    ·
    6 months ago

    I like this bit at the end:

    As a side note, the program is amazingly performant. For small numbers the results are instantaneous and for the large number close to the 2^32 limit the result is still returned in around 10 seconds.