I need to generate a random value from x to y having increment i.
where x is start value, y is end value.
so if x = 2 and y = 12 and i = 2
then random value should be generated from the following set
(2,4,6,8,10,12)
and if x = 1 then random number should be picked from the following set
(1,3,5,7,9,11)
I need to know both in MySQL and PHP and will choose whichever is simpler.
Thanks. 2 1255
..oO(Cosmic programmer)
>I need to generate a random value from x to y having increment i. where x is start value, y is end value.
so if x = 2 and y = 12 and i = 2
then random value should be generated from the following set
(2,4,6,8,10,12)
and if x = 1 then random number should be picked from the following set
(1,3,5,7,9,11)
I need to know both in MySQL and PHP and will choose whichever is simpler.
Read about 'for' loops.
Micha
"Cosmic programmer" <no**********@nowhere.comwrote in message
news:fu**********@registered.motzarella.org...
>
I need to generate a random value from x to y having increment i.
where x is start value, y is end value.
so if x = 2 and y = 12 and i = 2
then random value should be generated from the following set
(2,4,6,8,10,12)
and if x = 1 then random number should be picked from the following set
(1,3,5,7,9,11)
I need to know both in MySQL and PHP and will choose whichever is simpler.
Thanks.
Got it! in MySQL
start_val + inc * floor(rand()*(floor((end_val-start_val)/inc + 1)))
I'm a genious!!! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Alexander Schmolck |
last post by:
Quite a few algortihms prominently feature choosing/removing a single random
element from a set at a time. On first sight I can't think of anything better
to achieve this with `sets.Set` than...
|
by: R. Russell Kinter |
last post by:
Hi all,
First of all I am fairly new to javascript. Most of my experience has
been with
its subset vrmlscript, so have mercy.
The following script works in I.E. 5.5, but hangs up in Netscape 4.8...
|
by: yf |
last post by:
A KB article
"http://support.microsoft.com/default.aspx?scid=kb;en-us;209599" tells
that the maximum number of records that a table may hold if the PRIMARY
key data type is set to AUTONUMBER is...
|
by: Jonathan Burd |
last post by:
Greetings everyone,
Here is a random string generator I wrote for an application
and I'm wondering about the thread-safety of this function.
I was told using static and global variables cause...
|
by: abhi |
last post by:
How do you get random numbers in vb .net?
I want random six digit numbers.
Cheers,
Abhi
|
by: Adam Hartshorne |
last post by:
Hi All,
I was wondering if somebody could post a few lines of code which would
produce random colors, which will be used in defining different regions
on a mesh. So in addition to having n...
|
by: ssims |
last post by:
I've got this code for a random GDI+ chart generator, and the demo
works, but when I try to run it on my local machine I get a compiler
error: Compiler Error Message: CS0117: 'Random' does not...
|
by: Velhari |
last post by:
Hi,
I am a beginner. Please tell me, For generating Random Numbers, Initially why we are going for seed method.
And another question is that, I want to print unique random number how to print by...
|
by: momogi |
last post by:
I'm making a TSP (Travelling Salesman Problem) project in Simulated Annealing Method.
Here, I need to add a condition to the generated random value.
I wanna ask you, how to generate two random...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |