Page 1 of 1

Maths

Posted: Wed Jul 03, 2013 2:52 pm
by Micoute
Pourquoi PB est-il nul en math ?
Translation with Google Translation: Why PB is null in math?

Code: Select all

Global  Nombre_Initial.q, NombreTest.q, NombreTest2.q
Global NombreChiffres, Reducteur, Valeur_Retenue, i
Global.s Code
Global Dim Valeur.q(9)
Global NewMap Retenue()

Declare Decomposer(Nombre.q)
Declare Reduire(Nombre.q, Retenue)

Procedure Decomposer(Nombre.q)
  Nombre_Initial = Nombre.q
  ;Code.s = ""
  NombreTest = Nombre_Initial
  Retenue = 1
  NombreChiffres = Len(Str(NombreTest))+1
  Reducteur = Val(ReplaceString(Space(NombreChiffres)," ",Str(Retenue)))
  code + "(" + Left(Str(NombreChiffres), 2) + "."
  Debug  "Nombre    = " + Str(NombreTest)
  Debug "Réducteur = " + Str(Reducteur)
  Debug "Longueur  = " + Str(NombreChiffres)
  Debug Str(Reducteur) + " - " + Str(NombreTest) + " = " +Str(Reducteur-NombreTest)
  
  NombreTest2 = NombreTest
  Valeur(0) = NombreTest
  For i = 9 To 1 Step - 1
    Reducteur = Val(ReplaceString(Space(NombreChiffres-1)," ",Str(i)))
    If Reducteur > NombreTest2
      NombreTest2 = Reducteur - NombreTest2
      Debug "  " + Str(Reducteur) +  " - " + Str(NombreTest) + " = " + Str(NombreTest2)
    Else  
      NombreTest2 - Reducteur
      Debug "  " + Str(NombreTest) +  " - " + Str(Reducteur) + " = " + Str(NombreTest2)
    EndIf
    Valeur(i) = NombreTest2
    Retenue(Str(i)) = Valeur(i)
  Next i
  
  SortArray(Valeur(), #PB_Sort_Descending)
  
  Debug "****************RETENUE****************"
  Debug "Valeur retenue " + Str(Valeur(9))
  For i = 0 To 9
    If Retenue(Str(i)) = Valeur(9)
      Retenue = i
      Debug "Retenue = " + Str(Retenue)
    EndIf
  Next 
  
  Debug  ""
  Debug "Nombre initial = " + Str(Nombre_Initial)
  
  reduire(Valeur(9), Retenue)
  
EndProcedure

Procedure reduire(Nombre.q, Retenue)
  NombreTest = Nombre
  Valeur_Retenue = Retenue
  Debug ""
  Debug "********Réduction********"
  While NombreTest > 0
    Debug  "Nombre     = " + Str(NombreTest)
    NombreChiffres = Len(Str(NombreTest)) - 1
    reducteur = Val(ReplaceString(Space(NombreChiffres+1)," ",Str(Valeur_Retenue)))
    code + Str(Retenue) + ") "
    Debug "Réducteur = " + Str(Reducteur)
    ;Debug "Longueur  = " + Str(NombreChiffres)
    Debug "Code = " + code 
    NombreTest - reducteur
    Debug "Reste        = " + Str(NombreTest)
    Debug ""
    Debug "********Fin de réduction********"
    If NombreTest < 0
      Debug "Reste " + Str(NombreTest)
    Else  
      Decomposer(NombreTest)
    EndIf  
  Wend
EndProcedure

Decomposer(4867201436872539)
;CallDebugger

Re: Maths

Posted: Wed Jul 03, 2013 3:32 pm
by Little John
Micoute wrote:Pourquoi PB est-il nul en math ?
Hi,

I would like to try to answer your question, but unfortunately I don't understand French.
Please repeat your question in English, as that's the language which is spoken on this forum. Thanks.

Re: Maths

Posted: Wed Jul 03, 2013 6:20 pm
by Demivec
Use the right sized variables. The variable 'Reducteur' and the map 'Retenue()' need to be quads.

Code: Select all

Global  Nombre_Initial.q, NombreTest.q, NombreTest2.q
Global NombreChiffres, Reducteur.q, Valeur_Retenue, i
Global.s Code
Global Dim Valeur.q(9)
Global NewMap Retenue.q()

Re: Maths

Posted: Thu Jul 04, 2013 9:27 am
by Micoute
Demivec wrote:Use the right sized variables. The variable 'Reducteur' and the map 'Retenue()' need to be quads.

Code: Select all

Global  Nombre_Initial.q, NombreTest.q, NombreTest2.q
Global NombreChiffres, Reducteur.q, Valeur_Retenue, i
Global.s Code
Global Dim Valeur.q(9)
Global NewMap Retenue.q()
Thank you much, but it changes nothing in my problem

Re: Maths

Posted: Thu Jul 04, 2013 9:46 am
by Little John
Micoute wrote:Thank you much, but it changes nothing in my problem
So what exactly is your problem :?:
Micoute wrote:Why PB is null in math?
This is not understandable.
You must help a little yourself, so that we can help you.

Re: Maths

Posted: Thu Jul 04, 2013 10:20 am
by Micoute
Little John wrote:
Micoute wrote:Thank you much, but it changes nothing in my problem
So what exactly is your problem :?:
Micoute wrote:Why PB is null in math?
This is not understandable.
You must help a little yourself, so that we can help you.
I believe that will not get there because I only speak French and I trust google translation

Re: Maths

Posted: Thu Jul 04, 2013 11:36 am
by Crusiatus Black
You could communicate more easily here: http://purebasic.fr/french/ - The French forums for PureBasic. :)

Re: Maths

Posted: Fri Jul 05, 2013 11:50 am
by Micoute
Crusiatus Black wrote:You could communicate more easily here: http://purebasic.fr/french/ - The French forums for PureBasic. :)
I know, but the English are more reactive than the French

Re: Maths

Posted: Fri Jul 05, 2013 2:36 pm
by Demivec
Micoute wrote:I believe that will not get there because I only speak French and I trust google translation
It would help if you write more about what you are trying to do. When you write a longer and more detailed description then google translator will be more likely to have helpful results. When you write only a few words then google translator does not help much because it can't read your mind and doesn't know your thoughts. :)

Re: Maths

Posted: Fri Jul 05, 2013 4:07 pm
by Mindphazer
Micoute wrote:I trust google translation
You should not.