# How to do an "if" block in Sage?

I am trying to do an if block in sage. For example, I have code:

```
for n in range(7):
if gcd(n,3)==3:
n=n/3;
n=n+1;
print(n)
```

This "should" only add one when n is divisible by 3, but seems to do this all the time. Any ideas?

Specifically, I am trying to sum up al multinomial coefficients that have two equal parts. I am using the code: for n in range(21): t=0; for i in range(n+1): t = t + Combinations(n,i).cardinality()*Combinations(n-i,i).cardinality(); t=3*t; if gcd(n,3)==3: t = t-2*Combinations(n, n/3).cardinality()*Combinations(2*n/3, n/3).cardinality(); print t However, for n=3 the answer should be 18 not 15. Ideas?

Can you put the code from your comment in your original question so we can see the formatting better?

For your first bit of code, if you print n before and after your "if" block, you will see that the value of n is only modified when n is divisible by 3.