How can I generate random number with a range from to

I have the following code which generates a random number from 1 to 255 but I would like to add a range to the formula to be able to generate a number example starting form 1 to 10 only or from 25 to 100 and so on.

Here is the current code which is working perfectly.

void getRandomNum(){

uint8_t num_rand_bytes_available;
ret_code_t err_code;

err_code = sd_rand_application_bytes_available_get(&num_rand_bytes_available);
APP_ERROR_CHECK(err_code);
//if there is a randon number available
if(num_rand_bytes_available > 0)
{
err_code = sd_rand_application_vector_get(&random_number, 1);
APP_ERROR_CHECK(err_code);
}

}

Related