Easiest way to solve this problem [C++ code with command].
/***************************************************************************************************
Anzmaul Haque Akash
DIU, Daffodil International University
E-mail: anzamul15-2297@diu.edu.bd
Youtube:
https://www.youtube.com/channel/UCXvXHUkxyLYKeQkIg_RyMBw******************************************************************************************************/
#include<bits/stdc++.h>
#define ln (int)1e6
#define pi acos(-1.0)
#define pb push_back
#define pf push_front 1
#define mp make_pair
#define F first
#define S second
#define INF 1000000000000000000
#define LES -1000000000000000000
#define intlim 2147483648
#define ll long long
#define ull unsigned long long
#define str string
#define in insert
#define all(akash) akash.begin(),akash.end()
#define ms(arr) memset(arr,0,sizeof(arr))
#define msbooltrue(arr) memset(arr,true,sizeof(arr))
#define msboolfalse(arr) memset(arr,false,sizeof(arr))
#define msINF(arr) memset(arr,INF,sizeof(arr))
#define case1(cs) cout<<"Case "<<cs<<": "
#define case2(cs) cout<<"Case "<<cs<<":\n"
#define lb cout<<"\n";
#define vec vector
#define qu queue
#define li list
#define pq priority_queue
#define em empty
#define fori(i,a,b) for(int i=0;i<b;i++)
#define ford(i,a,b) for(int i=b-1;i>=0;i--)
#define forc(ch); for(char ch:str)
#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld %lld",&a,&b)
#define sc3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sc5(a,b,c,d,e) scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
using namespace std;
void solve(ll n){
ll temp_n=n;
temp_n--;
for(ll i=0; i<n-1; i++){
cout<<"(";
}
cout<<"sin(1)+"<<n<<")"; //Segment 1.
str s="sin(1-sin("; // if n>1 this one is using for the template.
for(ll i=2;i<=n;i++){ //main loop.
str temp;
temp.clear();
temp=s;
for(ll x=2; x<i;x++){ //This one creat middle of Every part.
if(x%2==0){ //' + ' for even ' - ' for odd.
temp+=to_string(x);
temp+="+sin(";
}
else{
temp+=to_string(x);
temp+="-sin(";
}
}
temp+=to_string(i);
for(ll y=1;y<=i;y++){ //for closing ' ) ' every equation.
temp+=")";
}
cout<<temp; //print each segment.
if(temp_n > 1){
cout<<"+"<<temp_n<<")"; //Printing every segment last digit with out 1.
}
temp_n--;
}
cout<<"+1";lb//This one for end.
}
int main()
{
ll n;
sc1(n);
if(n>1){
solve(n); //solve function.
}
else if(n==1){
cout<<"sin(1)+1";lb //for 1.
}
return 0;
}