We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Mathematics
- Algebra
- Easy sum
- Discussions
Easy sum
Easy sum
Sort by
recency
|
52 Discussions
|
Please Login in order to post a comment
//c++ code
include
using namespace std;
define endl '\n'
define ig cin.ignore()
define GET_FASTER ios_base::sync_with_stdio(false); cin.tie(NULL)
typedef long long int ll; const ll mx= LLONG_MAX; const ll mn= LLONG_MIN; const ll MOD= 1e9+7; bool descending_order(int x, int y){return x>y;}
long long nth_term(long long n){ return (n+(n*n))/2; }
int main(){
}
Power-efficient - Integrated GPUs consume less power than dedicated GPUs, which makes them ideal for use in laptops and other mobile devices. https://upgpu.com/best-gpu-for-i5-9400f/
Gauss's summation implemented in Python.
Explanation: Gauss's formula for summation states that the sum from 1 to N for any natural number, N, can be calculated arithmetically:
The problem statement implies an approach where one would loop from 1 up to n, taking mod m at each step.
However, with some out-of-the-box thinking, by applying the mod m ahead of time, you will see that in fact we are summing from 1 to m-1 over and over.
The number of times we take this sum is equal to
If m divides n, this will be the result to return.
However, if a remainder exists from the previous division, then there are a few more integers to add to the total. Simply apply Gauss's formula one more time,
how to run out of memory: it supposed to work, while the n array is small XD
C# function prototype provided won't work. Should be long not int.