human
What is a code to recaman 's sequence and the other steps required given the following:
Recaman 's sequence | Prints first n terms of Recaman sequence.
Create an array to store terms.
First term of the sequence is always 0.
Fill remaining terms using recursive formula ..
If arr [ i - 1 ] - i is negative or already exists ..
Driver code"
Solution in Python:
assistant
#Here is code to recaman 's sequence and the other steps required.
 def recaman ( n ) :
	arr = [ 0 ] * n
	arr [ 0 ] = 0
	print ( arr [ 0 ] , end = " , ▁ " )
	for i in range ( 1 , n ) :
		curr = arr [ i - 1 ] - i
		for j in range ( 0 , i ) :
			if ( ( arr [ j ] == curr ) or curr < 0 ) :
				curr = arr [ i - 1 ] + i
				break
		arr [ i ] = curr
		print ( arr [ i ] , end = " , ▁ " )
n = 17
recaman ( n )