Skip to content

Commit

Permalink
Add better solution
Browse files Browse the repository at this point in the history
  • Loading branch information
lamhoangtung committed Jul 17, 2018
1 parent 9c87851 commit 182e927
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Binary file modified .DS_Store
Binary file not shown.
10 changes: 8 additions & 2 deletions Assignment 1/assignment1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ void dec(int &n){
}

float p(float x,int n){
float ans = 2018*pow(x,n);
float temp=1;
for (int i=1;i<=n;i++){
temp*=x;
}
float ans=2018*temp;
temp=x;
for (int i=2;i<=n;i++){
ans += (pow(x,i)/pow(3,i-1));
temp*=x/3.0;
ans+=temp;
}
return ans;
}
Expand Down

0 comments on commit 182e927

Please sign in to comment.