Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7596447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:55:10+00:00 2026-05-30T21:55:10+00:00

Given the pseudocode : e = 1 sum = 1 for i=2 upto n

  • 0

Given the pseudocode :

e = 1
sum = 1
for i=2 upto n
  e *= 10
  sum += i * e

Doing exponential suing multiplication since it’s much faster. Assuming n can be 10 ^ 1000 or bigger how would you go about getting the big O notation for something like this.

Of course it’s going to be at a minimum O(n), but how much does the multiplication and addition add to the complexity. Again, with large numbers.

I’m currently doing this in Ruby. I presume each language has a different way of implementing math operations so a general solution is fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:55:11+00:00Added an answer on May 30, 2026 at 9:55 pm

    For this to work with n as large as 10^1000 you would definitely need to use a BigNumber implementation for the arithmetic operations.

    Since you’re using a software implementation for the arithmetic operations that means that their time complexity will likely depend on the size (number of bits) of the numbers you’d be working with. In case of addition, the complexity would likely be linear and for multiplication it will be quadratic or in any case supra-linear.

    In that case all you have to do is plug that complexity into your algorithm above to obtain the combined complexity.

    For instance, if you have:

    for i = 2 to n
       <multiplication operation>
    

    Assuming the multiplication is quadratic in the size (# of bits) of n then O(mult) = (log n) ^ 2. Then the big-Oh complexity of the for-loop will be:

    n * O(mult) = O(n * ((log n) ^ 2))
    

    In your example, the for loop contains three potentially “expensive” operations:

    for i = 2 to n
       e *= 10          //   e = e * 10
       sum += i * e     //   sum = sum + i * e
    

    In the above, the expensive operations are: mult1: e*10, mult2: i * e, and add: sum + (result of i*e)

    Their combined complexity is going to be O(mult1 + mult2 + sum), which is going to take the value of the largest of three. In this case, definitely mult2

    So if you can obtain a bound on the multiplication operation then the total is complexity is going to be, as stated above: n * O(mult), which again, assuming a quadratic implementation in the size of numbers, is going to translate to something like: O(n * log(n))

    As far as estimating the run-time characteristics of arithemetic operations, here’s a nice table from Wikipedia of different algorithms for basic arithmetic operations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the URL (single line): http://test.example.com/dir/subdir/file.html How can I extract the following parts using
Given this code snippet that can be readily pasted into Linqpad (or slightly modified
I'm doing a Simulated Annealing algorithm to optimise a given allocation of students and
I have the following pseudocode: sum<-0 inc<-0 for i from 1-n for j from
How can I determine who the authors of a package are? Given that we
Given this simple 2-step pseudocode: 1. request for a file listing 2. download each
The question Given a path like thus: G:\path\foo\..\bar\baz.txt Which we can immediately parse in
can someone give me a hint on how a histogram's pseudo code would look
Given a specific DateTime value, how do I display relative time, like: 2 hours
Given a Python object of any kind, is there an easy way to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.