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. General Programming
  3. C / C++ / MFC
  4. Handling large numbers

Handling large numbers

Scheduled Pinned Locked Moved C / C++ / MFC
comalgorithms
6 Posts 5 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.
  • M Offline
    M Offline
    Member_14849246
    wrote on last edited by
    #1

    #include void main() { int t,j; scanf("%d",&t); for(j=0;j Conject-It ! | Basics of Input/Output & Basic Programming Practice Problems | HackerEarth[^]

    OriginalGriffO CPalliniC D 3 Replies Last reply
    0
    • M Member_14849246

      #include void main() { int t,j; scanf("%d",&t); for(j=0;j Conject-It ! | Basics of Input/Output & Basic Programming Practice Problems | HackerEarth[^]

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      No. We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you. So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in! Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • M Member_14849246

        #include void main() { int t,j; scanf("%d",&t); for(j=0;j Conject-It ! | Basics of Input/Output & Basic Programming Practice Problems | HackerEarth[^]

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        You should find another (algorithmic) approach. Dealing with such huge numbers (order of 2333) is far beyond the possibilities of the standard C/C++ integer types.

        In testa che avete, signor di Ceprano?

        1 Reply Last reply
        0
        • M Member_14849246

          #include void main() { int t,j; scanf("%d",&t); for(j=0;j Conject-It ! | Basics of Input/Output & Basic Programming Practice Problems | HackerEarth[^]

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Just an observation... The only condition that will exit the while() loop is when num is equal to 1. The if() test after that will always print YES.

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

          P 1 Reply Last reply
          0
          • D David Crow

            Just an observation... The only condition that will exit the while() loop is when num is equal to 1. The if() test after that will always print YES.

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

            P Offline
            P Offline
            Peter_in_2780
            wrote on last edited by
            #5

            A well known conjecture: Collatz conjecture - Wikipedia[^] (with many other names too). Cheers, Peter

            Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

            D 1 Reply Last reply
            0
            • P Peter_in_2780

              A well known conjecture: Collatz conjecture - Wikipedia[^] (with many other names too). Cheers, Peter

              Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              Given the OP's code, I was simply pointing out that if too few operations are done, some numbers won't reach 1. For example, 47 takes 103 operations in order to reach 1, and 231 and 235 both take 127 operations in order to reach 1.

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

              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