Maths

Just starting out? Need help? Post your questions and find answers here.
Micoute
User
User
Posts: 28
Joined: Sat Jun 22, 2013 4:06 pm
Location: La Mézière FRANCE

Maths

Post 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
Last edited by Micoute on Wed Jul 03, 2013 4:27 pm, edited 2 times in total.
Little John
Addict
Addict
Posts: 4789
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Maths

Post 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.
User avatar
Demivec
Addict
Addict
Posts: 4269
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Maths

Post 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()
Micoute
User
User
Posts: 28
Joined: Sat Jun 22, 2013 4:06 pm
Location: La Mézière FRANCE

Re: Maths

Post 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
Little John
Addict
Addict
Posts: 4789
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Maths

Post 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.
Micoute
User
User
Posts: 28
Joined: Sat Jun 22, 2013 4:06 pm
Location: La Mézière FRANCE

Re: Maths

Post 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
User avatar
Crusiatus Black
Enthusiast
Enthusiast
Posts: 389
Joined: Mon May 12, 2008 1:25 pm
Location: The Netherlands
Contact:

Re: Maths

Post by Crusiatus Black »

You could communicate more easily here: http://purebasic.fr/french/ - The French forums for PureBasic. :)
Image
Bas Groothedde,
Imagine Programming

I live in a philosophical paradoxal randome filled with enigma's!
Micoute
User
User
Posts: 28
Joined: Sat Jun 22, 2013 4:06 pm
Location: La Mézière FRANCE

Re: Maths

Post 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
User avatar
Demivec
Addict
Addict
Posts: 4269
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Maths

Post 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. :)
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 460
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: Maths

Post by Mindphazer »

Micoute wrote:I trust google translation
You should not.
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
Post Reply