Click here to Skip to main content
15,886,693 members
Home / Discussions / C#
   

C#

 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
FunkySteve23-Aug-11 2:47
FunkySteve23-Aug-11 2:47 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
stephen.darling23-Aug-11 3:00
stephen.darling23-Aug-11 3:00 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
KP Lee23-Aug-11 8:43
KP Lee23-Aug-11 8:43 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
riced23-Aug-11 8:56
riced23-Aug-11 8:56 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
KP Lee23-Aug-11 9:56
KP Lee23-Aug-11 9:56 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
riced24-Aug-11 6:56
riced24-Aug-11 6:56 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
KP Lee24-Aug-11 9:58
KP Lee24-Aug-11 9:58 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
riced24-Aug-11 10:21
riced24-Aug-11 10:21 
Here's my original post: (the add 10 is redundant - me being silly)
Generate a four digit random number,
multiply it by 10,
add 5 (or 10).
The result will be divisible by 5.


The adding 5 could be done at random.
The Random class in C# allows you to get next integer in a range e.g. x = Random.Next(0, 10000) gets you a number on range 0 to 9999 (the second parameter is the exclusive upper limit). So no need to mess about multiplying by 100k. He could use Random.Next(1000, 10000) if he actually requires, or just use String formatting if it's just to be displayed.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.

GeneralRe: How do I generate a number divisable by 5, and check it? Pin
Gary Wheeler23-Aug-11 1:13
Gary Wheeler23-Aug-11 1:13 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
Kenneth Kasajian23-Aug-11 3:18
Kenneth Kasajian23-Aug-11 3:18 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
stephen.darling23-Aug-11 3:48
stephen.darling23-Aug-11 3:48 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
Kenneth Kasajian28-Aug-11 11:30
Kenneth Kasajian28-Aug-11 11:30 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
stephen.darling28-Aug-11 11:41
stephen.darling28-Aug-11 11:41 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
Kenneth Kasajian28-Aug-11 18:48
Kenneth Kasajian28-Aug-11 18:48 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
RDSchaefer23-Aug-11 4:11
RDSchaefer23-Aug-11 4:11 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
stephen.darling23-Aug-11 5:34
stephen.darling23-Aug-11 5:34 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
RDSchaefer23-Aug-11 6:07
RDSchaefer23-Aug-11 6:07 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
stephen.darling23-Aug-11 6:52
stephen.darling23-Aug-11 6:52 
SuggestionRe: How do I generate a number divisable by 5, and check it? PinPopular
Simon Bang Terkildsen22-Aug-11 5:26
Simon Bang Terkildsen22-Aug-11 5:26 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
mooman2723-Aug-11 10:34
mooman2723-Aug-11 10:34 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
riced24-Aug-11 6:58
riced24-Aug-11 6:58 
GeneralMessage Removed PinPopular
22-Aug-11 4:00
David198722-Aug-11 4:00 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
stephen.darling22-Aug-11 23:19
stephen.darling22-Aug-11 23:19 
AnswerRe: How do I generate a number divisable by 5, and check it? Pin
Tom Chantler23-Aug-11 1:15
professionalTom Chantler23-Aug-11 1:15 
GeneralRe: How do I generate a number divisable by 5, and check it? Pin
Member 462161222-Sep-11 4:53
Member 462161222-Sep-11 4:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.