• nova_ad_vitum@lemmy.ca
    link
    fedilink
    English
    arrow-up
    0
    ·
    11 months ago

    Sorry if this is stupid but how to deal with sums to odd numbers ? Won’t you have a number left over after pairing all the others?

    • Trailblazing Braille Taser@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      1
      arrow-down
      1
      ·
      11 months ago

      Nope, because what you’re doing is copying the entire sequence, reversing it, and pairing up each element left to right. There’s no way to have any leftovers because the original sequence and the new reversed sequence have the same number of elements.

      A perhaps less intuitive way of thinking of it is you start with a sequence of 1 up to N, which contains exactly N elements. The sequence from 1 to N and its reverse together contain 2N elements, which is by definition an even number, regardless of whether N is even or odd. Because it’s even we can break it into pairs without leftovers.