This question has already been answered:
S = 1 + 2 ^ 2 + 3 ^ 3 + ... + N ^ N
Model the arithmetic cycle with the for loop operator. The exponentiation formula is not used.
This question has already been answered:
S = 1 + 2 ^ 2 + 3 ^ 3 + ... + N ^ N
Model the arithmetic cycle with the for loop operator. The exponentiation formula is not used.
A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .
Here, try:
int N=20,S=0, P=1; for(int i=1;i<=N;i++){ P=1; for(int j=1;j<i;j++){ P = P*i; } S = S+P; } Do not try to try the above!
const int N = 20; long int S = 1; for(int i = 2; i <= N; i++) { long int P = 1; for(int j = 1; i <= j; j++) { P *= i; } S += P; } Source: https://ru.stackoverflow.com/questions/43882/
All Articles