Author Topic: Water lily puzzle  (Read 2925 times)

0 Members and 1 Guest are viewing this topic.

Offline Kernelpanic

  • Newbie
  • Posts: 94
    • View Profile
Water lily puzzle
« 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.  
Mark Twain
"Als wir das Ziel endgültig aus den Augen verloren hatten, verdoppelten wir unsere Anstrengungen."
„Having lost sight of our goals, we redoubled our efforts.“

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Water lily puzzle
« Reply #1 on: October 19, 2020, 02:41:12 pm »
If area doubles daily then x-1 days ;-))

Offline Kernelpanic

  • Newbie
  • Posts: 94
    • View Profile
Re: Water lily puzzle
« Reply #2 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. ;)
Mark Twain
"Als wir das Ziel endgültig aus den Augen verloren hatten, verdoppelten wir unsere Anstrengungen."
„Having lost sight of our goals, we redoubled our efforts.“