# Is there a method or a function to generate integers that are only divisible by 3?

Is there a method or a function to generate integers that are only divisible by 3?

• If you mean by $3$ and no other prime, then $3^n$. Jan 6, 2013 at 4:48
• @RahulNarain $3*4=12$, $12 mod2 = 0$ Jan 6, 2013 at 4:51
• What do you mean? If $n$ is an integer divisible by $3$, then we have another integer $n/3$ which also divides $n$. So I guess the only solution to your problem is the constant function $3$. Jan 6, 2013 at 4:55
• Wow...I just remembered the Fundamental Theorem of Arithmetic and realized how big of a brain fart that was. Jan 6, 2013 at 4:57
• I read "generate integers that are only divisible by 3" as "generate only integers that are divisible by 3", sorry.
– user856
Jan 6, 2013 at 5:07

Every integer is also divisible by $1$, so the collection is empty.

If you're OK with having $1$ as a divisor, every integer is also divisible by itself, so it's just $3$.

If you mean the set of integers for which $3$ is the only prime divisor then you may use the following algorithm:

 1. Let x = 3 and S be empty.
2. Add x and -x to S.
3. Multiply x by 3 and set x equal to that.
4. Go to 2.


There is no integer that is only divisible by $3$. Every integer is always divisible by $1$.