There are two types of formulas you can use to find the relation between notes— just intonation, and equal temperament; both of which have their benefits and trade-offs, which I will not go into in much detail in this answer, as it seems outside of the scope of your question.
First, a general rule, that holds true in both systems
To find a note an octave above another note, multiply its number by 2. To find a note an octave below another note, divide its number by 2.
In just intonation, the number you will be multiplying a pitch by will be a ratio between two whole numbers— you gave two examples in your question: 1/2 (or 0.5) and 2/1 (or 2.0).
Here are the fractions you should multiply your base note by to get the notes of the major scale in just intonation:
And here are the fractions for the notes of the minor scale:
The octave is divided into 12 semitones. In equal temperament, each of the semitones is the exact same size— the twelfth root of two. Thus, 1 semitone up equals 1 times the twelfth root of two, 2 semitones up equals 2 times the twelfth root of two, and so on. Here are the decimal approximations for the equal tempered intervals of the scale.
1 semitone/minor second: 1.059463
2 semitones/major second: 1.122462
3 semitones/minor third: 1.189207
4 semitones/major third: 1.259921
5 semitones/perfect fourth: 1.334840
6 semitones/tritone: 1.414214
7 semitones/perfect fifth: 1.498307
8 semitones/Minor sixth: 1.587401
9 semitones/major sixth: 1.681793
10 semitones/minor seventh: 1.781797
11 semitones/major seventh: 1.887749
12 semitones/ octave: 2.0
So which system should you use?
The intervals of just intonation have a purer sound. However, it only works in one key. If you set the ratios up for C major in just intonation and then play a D major scale or arpeggio, it will sound wrong. Since you're making a program, I'm assuming you want it to work in all keys, so I would say that equal temperament is the right formula for the job. Additionally, you mentioned you were using a piano sample. Pianos are tuned in equal temperament, so it will probably sound truer to a real piano sound if you use equal temperament.