Click here to Skip to main content
15,798,405 members
Home / Discussions / C#
   

C#

 
GeneralRe: Program Help Pin
OriginalGriff11-Aug-18 21:08
mvaOriginalGriff11-Aug-18 21:08 
GeneralRe: Program Help Pin
AnotherKen18-Aug-18 10:04
professionalAnotherKen18-Aug-18 10:04 
GeneralRe: Program Help Pin
Mycroft Holmes18-Aug-18 14:30
professionalMycroft Holmes18-Aug-18 14:30 
GeneralRe: Program Help Pin
AnotherKen18-Aug-18 20:18
professionalAnotherKen18-Aug-18 20:18 
AnswerRe: Program Help Pin
Richard Andrew x6412-Aug-18 4:32
professionalRichard Andrew x6412-Aug-18 4:32 
QuestionSplit a number into multiple number in a specific way Pin
Mou_kol10-Aug-18 12:14
Mou_kol10-Aug-18 12:14 
AnswerRe: Number distribution in a specific way Pin
Mycroft Holmes10-Aug-18 14:34
professionalMycroft Holmes10-Aug-18 14:34 
AnswerRe: Number distribution in a specific way Pin
Luc Pattyn11-Aug-18 7:22
sitebuilderLuc Pattyn11-Aug-18 7:22 
Hi,

I'm confused, your code is implementing something that is harder than what your requirements stipulate, assuming I understood them correctly, as in: generate N positive integers totalling SUM, where the first N-1 numbers are identical and maximal.

If so, this would be the "algorithm" for N>0 and SUM>=0:
for(int i=0; i<N-1; i++) yield return SUM/N;    // first N-1 numbers
yield return SUM-SUM/N*(N-1);                   // making sure total equals SUM


As this is an integer problem, no doubles are involved; for positive numbers integer divide returns the (floored) quotient.

Further comment: I see no need to order the list as you do, and if you really want a List<int> then why do you use IEnumerable.ToList, your method could create a List<int> straight away...

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

QuestionGet file metada Pin
Member 1193763910-Aug-18 1:04
Member 1193763910-Aug-18 1:04 
AnswerRe: Get file metada Pin
Richard MacCutchan10-Aug-18 1:22
mveRichard MacCutchan10-Aug-18 1:22 
QuestionRDP connections in tabs Pin
Member 114416229-Aug-18 20:41
Member 114416229-Aug-18 20:41 
AnswerRe: RDP connections in tabs Pin
Mycroft Holmes9-Aug-18 21:20
professionalMycroft Holmes9-Aug-18 21:20 
GeneralRe: RDP connections in tabs Pin
Member 1144162213-Aug-18 0:54
Member 1144162213-Aug-18 0:54 
GeneralRe: RDP connections in tabs Pin
Pete O'Hanlon13-Aug-18 1:27
subeditorPete O'Hanlon13-Aug-18 1:27 
GeneralRe: RDP connections in tabs Pin
Member 1144162213-Aug-18 2:17
Member 1144162213-Aug-18 2:17 
GeneralRe: RDP connections in tabs Pin
Pete O'Hanlon13-Aug-18 2:23
subeditorPete O'Hanlon13-Aug-18 2:23 
GeneralRe: RDP connections in tabs Pin
Mycroft Holmes13-Aug-18 3:16
professionalMycroft Holmes13-Aug-18 3:16 
GeneralRe: RDP connections in tabs Pin
Member 1144162213-Aug-18 4:10
Member 1144162213-Aug-18 4:10 
GeneralRe: RDP connections in tabs Pin
Mycroft Holmes13-Aug-18 14:28
professionalMycroft Holmes13-Aug-18 14:28 
QuestionClasses In Threads - Pause One Until Another Finished Pin
Kevin Marois8-Aug-18 7:43
professionalKevin Marois8-Aug-18 7:43 
AnswerRe: Classes In Threads - Pause One Until Another Finished Pin
Richard Deeming8-Aug-18 9:05
mveRichard Deeming8-Aug-18 9:05 
AnswerRe: Classes In Threads - Pause One Until Another Finished Pin
OriginalGriff8-Aug-18 9:09
mvaOriginalGriff8-Aug-18 9:09 
GeneralRe: Classes In Threads - Pause One Until Another Finished Pin
Kevin Marois8-Aug-18 9:22
professionalKevin Marois8-Aug-18 9:22 
GeneralRe: Classes In Threads - Pause One Until Another Finished Pin
OriginalGriff8-Aug-18 23:08
mvaOriginalGriff8-Aug-18 23:08 
GeneralRe: Classes In Threads - Pause One Until Another Finished Pin
Richard Deeming9-Aug-18 1:48
mveRichard Deeming9-Aug-18 1:48 

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.