Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
series
//g++ 7.4.0 //arithmetic series: sum,sum of squares and sum of cubes //created by Rezaul Hoque on December 08,2020 // #include <iostream> #include <cmath> using namespace std; int main () { float n= 2.0; float m= pow((n+1),2); float sum, sum2, sum3; //Sum of first n natural numbers sum= n*(n+1)/2; //sum of squares of first n natural numbers sum2=n*(n+1)*(2*n+1)/6; //sum of cubes of first n natural numbers sum3= n*m/2; cout<<"sum of first "<<n <<" natural numbers:\n"; cout<<sum; cout<<endl; cout<<"sum of squares of first "<<n <<" natural numbers:\n"; cout<<sum2; cout<<endl; cout<<"sum of cubes of first "<<n <<" natural numbers:\n"; cout<<sum3; return 0; }
run
|
edit
|
history
|
help
0
Dar
12hours Clock c++
LRU - DLL
My calculator
MyList
DailyExchRate2
Elevator
g++ -Wall *.cpp -o aco; ./aco.
MovConstrAssign4
How to get base class