1 Samuel 16:1013 Jesse had 8 sons, David was the youngest of them
1 Chronicles 2:1315 Jesse had only 7 sons where David is counted as the 7th son
This apparent contradiction is caused by assumptions, and it is solved when one recognizes certain points about those books of the Bible where these points are mentioned and when things are not taken as facts which are not mentioned as such in the Bible.
The record in 1 Samuel 16 gives the story, it reports so to say the historical sequence of events. The emphasis is put on describing the events in their historical sequence and with the respective context. The record in 1 Chronicles 2 on the other hand has a different purpose and goal, it is a record about the genealogies in which the immediate historical setting must be kept separate altogether.
In the historic record 7 other sons of Jesse in addition to David are mentioned, and all of them were older than David. The mention of the sons of Jesse is in the context of the election and anointing of David as king of Israel. At that time, a total of 8 sons of Jesse are mentioned. The record in 1 Chronicles 2 about the genealogies mentions only a total of 7 sons of Jesse, and David is said to be the youngest. The omission of one of the sons in this record could mean that (1) in the meantime one of the older sons had died and is therefore not mentioned in this list, or that (2) one of the sons possibly was the son of a second wife, or that (3) one of the sons himself did not have any descendants and therefore is not mentioned in this genealogical listing.
Both records in God's Word are true and really do not contradict each other. One has to consider the viewpoint and purpose of each record. Not every place must always give all the details and all the information about a certain matter, but those details mentioned will always be correct and true.