### Re^2: Read file text and find fibonacci series

by vr (Hermit)
 on Jan 03, 2018 at 00:01 UTC ( #1206569=note: print w/replies, xml ) Need Help??

Hi, haukex.

while (/(?=(\$re))./g) { ... }

"Look for a fib anywhere ahead, then if found, consume its leftmost digit, then repeat" probably makes no sense, even for this assignment/homework. The %fib was built but not actually used. The "3 element" part of assignment (not addressed in your code) could be either consecutive, or just ascending fibs. But, the way %fib was constructed, it may be to help looking for a fib whose initial digits are a fib too, whose initial digits, ..., etc. While leftmost digit of any 2-digit fib is a fib, -- I wonder if any value of %fib could be an array with more than 3 elements? :)

P.S. Please, I'm not appealing to rewrite anything, don't waste your time, the task is too much unclear.

P.P.S. And, I suspect the "PERFECT SQUARE" in OP, in C, won't work for 6-digit numbers and int type, because of overflow?

Replies are listed 'Best First'.
Re^3: Read file text and find fibonacci series
by haukex (Abbot) on Jan 03, 2018 at 09:00 UTC
The %fib was built but not actually used.

Well not quite, it is used for what you said:

to help looking for a fib whose initial digits are a fib too

This is what I was using it for, since I didn't feel like getting too fancy with the regex. The code I wrote was mostly just an implementation of my interpretation of the description the OP gave:

"Check 4 is fibonacci number , no , go ahaed 49 is fibonacci number , no, next 496 is fibonacci ,no, 4969 after 44693 [sic] ,after 496934 no.There isnt any fibonacci , go to next digit and do it again 9 , 96,969,9693,96934."
I wonder if any value of %fib could be an array with more than 3 elements?

Good question, I didn't try cranking up \$DIGITS past 60 yet...

the task is too much unclear

Agreed, which is why I just implemented the part I (thought I) understood ;-)

Create A New User
Node Status?
node history
Node Type: note [id://1206569]
help
Chatterbox?
 [Corion]: ambrus: I think there was some discussion and maybe even an entry in Tidings, but I'm not really sure [marto]: Back later, got to get the kids ready [ambrus]: Also, I still have the suspicion that Perlmonks as a website is still horribly insecure, and that a malicious attacker could take over anyone's account easily, and I should tell the details of why I think this in some Cabal-only place. [Corion]: But the site now is on https (only), and now also with one unified SSL certificate for all PM hoss [ambrus]: This worries me a lot especially because as a cbstream maintainer, if this happens, I could get falsely blamed for any insecurity. [ambrus]: Cbstream itself is also insecure because I abandonned it for too long, and it's really ripe for a full rewrite or something now. [ambrus]: But that's a totally different issue.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2018-07-19 08:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

Results (404 votes). Check out past polls.

Notices?