# Recurrence Relation construction [closed]

How can I go about setting up a recurrence relation where the first 10 values are a constant and the second 10 values are another constant?

Ideally, I'd like an efficient way to set

a[1] = 200
a[2] = 200
a[3] = 200
a[4] = 100
a[5] = 100


And so on, without having to type each term out explicitly.

-

## closed as unclear what you're asking by Szabolcs, m_goldberg, bobthechemist, rasher, belisariusMar 14 at 3:39

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

This question is not formulated very clearly so it is at risk of being closed. I recommend you rephrase it to make sure people understand what you're looking for, preferably by including a simple example. –  Szabolcs Mar 13 at 15:43
Like this? Do[a[i]=100,{i,1,5}]; Do[a[i]=200, {i,6,10}] –  Szabolcs Mar 14 at 0:35

Do you mean this?

In[85]:= Clear[f]
f[a_,b_]:=Flatten[ConstantArray[#,10]&/@{a,b}]
f[1,2]
Out[87]= {1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2}

-

 a[1]=200
a[4]=100
a[i_]:=a[i-1]

-

Here's a general approach using Map (represented by /@)

(a[#] = 1) & /@ Range[1, 5];
(a[#] = 2) & /@ Range[6, 10];


So now, for instance, a[2]=1 and a[7]=2.

-