Pascal's Triangle is easy if you know Combinations.
Each element is simply: P(n,k) = (n!)/(k!*(n-k)!)
Where n is the number of rows and k is 0 -> n (position value)
A simple python implementation would be like:
Code:
>>> for n in range(5): #0 to 4 = 5 rows
... for k in range(n+1): # 0 to n = n elements
... print fact(n)/(fact(k)*fact(n-k)),
... print
...
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
>>>
About the sine one, you need two counters. One odd incrementing and another for (-1)^n indication (Sign change).
In python again:
Code:
>>> def sin(x,n): # x is value, n is the iteration amount, for precision?
... ans=0.0
... odd=1.0
... for p in range(n):
... ans+=((-1)**p)*((x**odd)/fact(odd)) #(-1)^n * (x^num/num!) and on and on and on, as your series goes.
... odd+=2.0 #increment odd number counter
... return ans
...
>>> sin(5,7)
-0.93758404902067816