QB64.org Forum

Active Forums => Programs => Topic started by: Kernelpanic on October 19, 2020, 02:34:54 pm

Title: Water lily puzzle
Post by: Kernelpanic on October 19, 2020, 02:34:54 pm
I am trying with math functions right now.

The text is:
Water lily puzzle
A water lily covers a pond completely after 'x' days. After how many days is the pond half covered?

At it I discovered a problem with the German keyboard in QB64. (New little Bugreport)

Code: QB64: [Select]
  1. 'Seerosenraetzel - 19. 0kt. 2020
  2.  
  3.  
  4. Declare Function Log10# (X#) Static
  5.  
  6. DIM Tage AS DOUBLE, Anzahl AS DOUBLE
  7.  
  8. y = 2.0
  9.  
  10. PRINT "Seerosenraetzel"
  11. PRINT "Eine Seerose bedeckt einen Teich nach 'x' Tagen vollstaendig."
  12. PRINT "Nach wie vielen Tagen ist der Teich halb bedeckt?"
  13. INPUT "Anzahl der Tage bis der Teich vollbedeckt ist: ", Tage
  14.  
  15. 'Anzahl der Rosen und Teich halbbedeckt
  16. Anzahl = ((y ^ Tage) / y)
  17.  
  18. Tage = (Log10(Anzahl) / Log10(y))
  19. PRINT USING "Der Teich ist nach ### Tagen halb bedeckt."; Tage
  20.  
  21.  
  22. 'Logarithmus zur Basis 10
  23. FUNCTION Log10# (X) STATIC
  24.   Log10 = LOG(X) / LOG(10.0)
  25.  
Title: Re: Water lily puzzle
Post by: bplus on October 19, 2020, 02:41:12 pm
If area doubles daily then x-1 days ;-))
Title: Re: Water lily puzzle
Post by: Kernelpanic on October 19, 2020, 04:21:01 pm
If area doubles daily then x-1 days ;-))
I know, it is an exercise only. - But twenty years ago or so, most people come mull over it. ;)