There are 3 basic ways to find out what the accidentals in a scale are and to naming key signatures so that you know what key you are in. You can use the circle of fifths as mentioned above. It is a method that works well and shows how all the Rules & Orders of Sharps & Flats fit together in 1 whole.
Secondly, if you are figuring a sharp scale the new sharp name will be a half step below the names of the key and you keep all of the earlier sharps. Using the Order of Sharps can be a shortcut - see below. If you are figuring a flat key scale, say F Major, you will count up 4 keys beginning on F. This tone will be B. Flat it. that is your last accidental in the Order of Flats Second, all scales have a pattern made up of whole and half steps. A half step is the distance from one key to the next, black or white. Just the very next key. A whole step is made up of 2 half steps or you can think of it as skipping 1 key. The pattern for a Major scale is: WWHWWWH. It looks complicated, but after you have done it a few times it gets much easier, especially if you use the keys on a piano.
Thirdly, you can follow the rules for naming keys. There are 4 that fit together. The order of sharps is Father Charles Goes Down And Ends Battle - using just the capital letters. The Rule of Sharps is that the name of the key is 1 half step above the last sharp. Therefore if your key signature has 5 sharps, they will be F#, C#, G#, D# & A#. The first 5 sharps in the order of sharps. The name of your key will be a 1/2 step above the final sharp, A#, so your answer is the key of B Major. The Order of Flats is different: BEAD Grows California Flowers, using only the capital letters. The Rule of Flats is also different: When you look at the flats in a key signature, the next to last flat in a key signature IS the name of the key. Therefore, if there are 4 flats they will be the first 4 flats in the Order of Flats: B flat, E flat, A flat & D flat and the name of the key will be A flat. It sounds complicated, but again, once you've done it a few times it gets much easier.
I would recommend learning the Orders of Sharps & Flats and the Rules for naming them as well. It will make life a lot simpler than trying to remember every key signature. Hope this helps!