Author Topic: Concatenation Coincidence  (Read 3755 times)

0 Members and 1 Guest are viewing this topic.

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Concatenation Coincidence
« on: October 30, 2021, 03:19:29 pm »
reference https://projecteuler.net/problem=751
Code: QB64: [Select]
  1. Dest Console
  2.  
  3. Option Explicit
  4. Dim As Float b
  5. Dim As Integer64 a
  6. Dim As Long i, j
  7. Dim As String s, s1, s2
  8.  
  9. s = "2."
  10. b = Val(s)
  11. For i = 1 To 14 Step 2
  12.     For j = 1 To i + 2
  13.         a = Fix(b)
  14.         'Print a
  15.         b = Fix(b) * (b - Fix(b) + 1)
  16.         s1 = s2
  17.         s2 = Str$(a)
  18.     Next
  19.     s = s + Trim$(s1) + Trim$(s2)
  20.     b = Val(s)
  21. Print s; " to "; Len(s) - 2; " places"
  22. b = Val(s)
  23. For i = 1 To 15
  24.     a = Fix(b)
  25.     Print a; " ";
  26.     b = Fix(b) * (b - Fix(b) + 1)
  27.  
output
Code: [Select]
2.223561019313554106173177195 to  27  places
 2   2   2   3   5   6   10   19   31   35   54   106   173   177   195
« Last Edit: October 30, 2021, 04:07:09 pm by jack »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Concatenation Coincidence
« Reply #1 on: October 30, 2021, 03:50:02 pm »
Hi jack,

If I plug in s = "2.95693889137788"
Shouldn't I get the same result as the reference link shows ie Fibonacci

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: Concatenation Coincidence
« Reply #2 on: October 30, 2021, 04:00:00 pm »
hi bplus
on bottom of the page it states the problem to be solved
Quote
Find the only value of θ for which the generated sequence starts at a1 = 2 and the concatenation of the generated sequence equals the original value: τ = θ.
Give your answer rounded to 24 places after the decimal point.

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: Concatenation Coincidence
« Reply #3 on: October 30, 2021, 04:11:35 pm »
maybe I misunderstood
Code: QB64: [Select]
  1. b = 2.95693889137788
  2. For i = 1 To 9
  3.     a = Fix(b)
  4.     Print a; " ";
  5.     b = Fix(b) * (b - Fix(b) + 1)
  6.  
Code: [Select]
2   3   5   8   13   21   34   55   89

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Concatenation Coincidence
« Reply #4 on: October 30, 2021, 04:16:07 pm »
Yeah your edit in OP works for me now too.

Did not see problem at bottom of page.

Every now and then I see something interesting pop up from Project Euler.