Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Math Puzzle (SOLVED by harold aptroot!)

Math Puzzle (SOLVED by harold aptroot!)

Scheduled Pinned Locked Moved The Lounge
csscomquestion
41 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S supercat9

    Here's a smaller approach:

            y = x + 7 \* (1 / (x \* x + 1))
    

    Assuming integer division, and assuming numbers don't overflow, this should work nicely. The expression x*x is never negative, so x*x+1 is always positive and never zero. The expression 1/q is one when q=1, and zero if q>1; I don't think things can get any simpler than that.

    A Offline
    A Offline
    AspDotNetDev
    wrote on last edited by
    #41

    Very nice. And easily verifiable. I like. :thumbsup:

    [Forum Guidelines]

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups