The scoring is based roughly equally on speed and accuracy.
In daily challenges, the maximum score is 1000, although it is practically impossible to get that score. To get a score of 1000, you need to answer perfectly within the first 1 second. The maximum available score decreases linearly until 9 seconds have elapsed, after which point you get 500 points for a perfect answer. This means you can think 500 points as being lost as the penalty for taking most of the time to answer.
The accuracy of your answer is considered based on the absolute difference between your answer and the correct answer, as a percentage of the correct answer. This percentage is judged using an exponential decay curve (meaning it drops quickly), where you get less than 1% of the maximum available score if you're answer is off by 100% or more (eg. if your guess is double the correct answer).
Scoring in random mode is similar but not quite the same.
The number of points available is based on a combination of how many numbers you have to add up and the time limit. How it works is based on the idea that if you have either double the amount of numbers, or half the amount of time, you should get up to twice as many points as the daily challenge game, so 2000 points are available.
The same general logic behind the penalty for time usage applies, which means that you lose 0 points in the first 10% of the time limit, and lose 50% of the points if you answer in the last 10% of the time limit. A result of this is that you get a different score when the time limit is different, even when the time taken is the same.
The judgment of accuracy in random mode works the same, you get a portion of the available points after subtracting your time penalty, based on the same exponential decay curve.