Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need Math Whiz - Frankenbach ?
Message
From
17/02/2005 21:15:52
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00987308
Message ID:
00988195
Views:
39
Thanks, Dave . Between your answer and walter's I may even begin to understand *why* it works :-)

( any insights you have on my next dillema - Error 1585 Update Conflict - in client -server thread also appreciated. )


>Charles,
>
>I didn't see the thread last night and that Walter already got you one answer, but FWIW here's another solution:
>
>
? breakit( 10, 2 )
>? breakit( 3, 3 )
>? breakit( 10, 4 )
>? breakit( 4, 3 )
>? breakit( 5, 3 )
>? breakit( 6, 3 )
>? breakit( 100, 47 )
>
>function breakit( v, n )
>
>local lcRetVal, lnDivisor
>
>if ( mod( v, n ) = 0 )
>   * v is evenly divisible by n
>   lcRetVal = replicate( transform( v / n ) + ",", n )
>   lcRetVal = left( lcRetVal, len( lcRetVal ) - 1 )
>else
>   lnDivisor = floor( v / ( n - 1 )  )
>   if ( lnDivisor * ( n - 1 ) = v )
>      lnDivisor = lnDivisor - 1
>   endif
>   lcRetVal = replicate( transform( lnDivisor ) + ",", n - 1 ) + transform( v - lnDivisor * ( n - 1 ) )
>endif
>
>return lcRetVal
>
>
>>I knew I shouldn't have majored in history.
>>
>>I need to divide a value v into n integers i where n is fixed and if mod(v,n)>0 then the first n-1 i's must be equal with the nth i being the mod
>>
>>Does that make sense? If I divide 10 into 4 parts i need 3,3,3,1
>>
>>A couple of times I thought I was on the edge of actually getting it but ...
>>
>>Do I see any hands?


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Previous
Reply
Map
View

Click here to load this message in the networking platform