Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n=gets.to_i
- d=[]
- d[0]=0
- o="0 "
- if n>1
- d[1]=1
- o+="1 "
- n.times do|x|
- if x>1
- d[x]=d[x-1]+d[x-2]
- o+=d[x].to_s+' '
- end
- end
- end
- puts o[0..-2]
- # for golf
- n=gets.to_i;d=[];d[0]=0;o="0 ";if n>1;d[1]=1;o+="1 ";n.times do|x|;if x>1;d[x]=d[x-1]+d[x-2];o+=d[x].to_s+' ';end;end;end;puts o[0..-2]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement