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

  • SEARCH
  • Home
  • 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 658239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:54:40+00:00 2026-05-13T22:54:40+00:00

So I have a counter. It is supposed to calculate the current amount of

  • 0

So I have a counter. It is supposed to calculate the current amount of something. To calculate this, I know the start date, and start amount, and the amount to increment the counter by each second. Easy peasy. The tricky part is that the growth is not quite linear. Every day, the increment amount increases by a set amount. I need to recreate this algorithmically – basically figure out the exact value at the current date based on the starting value, the amount incremented over time, and the amount the increment has increased over time.

My target language is Javascript, but pseudocode is fine too.

Based on AB’s solution:

var now = new Date();

var startDate1 = new Date("January 1 2010");
var days1 = (now - startDate1) / 1000 / 60 / 60 / 24;
var startNumber1 = 9344747520;
var startIncrement1 = 463;
var dailyIncrementAdjustment1 = .506;
var currentIncrement = startIncrement1 + (dailyIncrementAdjustment1 * days1);

startNumber1 = startNumber1 + (days1 / 2) * (2 * startIncrement1 + (days1 - 1) * dailyIncrementAdjustment1);

Does that look reasonable to you guys?

  • 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-13T22:54:41+00:00Added an answer on May 13, 2026 at 10:54 pm

    It’s a quadratic function. If t is the time passed, then it’s the usual at2+bt+c, and you can figure out a,b,c by substituting the results for the first 3 seconds.

    Or: use the formula for the arithmetic progression sum, where a1 is the initial increment, and d is the “set amount” you refer to. Just don’t forget to add your “start amount” to what the formula gives you.

    If x0 is the initial amount, d is the initial increment, and e is the “set amount” to increase the incerement, it comes to
    x0 + (t/2)*(2d + (t-1)*e)

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

Sidebar

Related Questions

I have a counter that counts up every 1 second and add 1 to
I have a performance counter category. The counters in this category may change for
supposed I have a table with three columns: user_to, user_from, counter. I'm trying to
Suppose I have a function that tries to protect a global counter using this
I have this code which is supposed to fire on mouseover and it's counterpart
I have this php code: <?php if(!file_exists('counter.txt')){ file_put_contents('counter.txt', '0'); } if($_GET['click'] == 'yes'){ file_put_contents('counter.txt',
I have this assembler code, which I'm supposed to translate into machine code in
I currently have this block: if ($type == up) { $lines_ = file('../indexIncomplete'); $counter
We are supposed to calculate e^x using this kind of formula: e^x = 1
I have a counter hash that I am trying to sort by count. The

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.