Yes, just define the function. i.e. Use the Fibonacci numbers. What are good practices to perform it? (Vague, let's get specific.)
- Create list of Fib.s 0, to 1,000,000.
- Make function _Integer parameter, name fibonacciQ.
- Error trap with message if < 0, or > million.
Is that how, to do it? My real GOAL is any {x,y,z} of Pythagorean Triples (not {3,4,5}, or {3,10}, or {3,4,4,5} eg.), only one value tested per call, create a predicate function pythagoreanQ[ ] for them. Likely, load table from disk, when needed in a notebook. Is that my only practical alternative, unless computing pythags 3 .. 1,000,000 directly every time?
Thanks for answering.
fibQ = TrueQ[# == Fibonacci@Round[Log[GoldenRatio, Sqrt[5] #]]] &
?pythagQ = TrueQ[#1^2 + #2^2 == #3^2] &
orpythagQ = TrueQ[{1, 1, 1} . #^2 == 0] &
? $\endgroup$pythagoreanQ[{3,4,5}]
should returnFalse
? "Select[ {3,13, 100, 17} returns {True, True, True, True}" seems to make no sense since{3,13,100,17}
is not a triple at all. AlsoSelect[]
is a built-in function that does not return a list ofTrue
unless the input containedTrue
. Do you meanpQ[n]
should returnTrue
ifn
is a member of any Pythagorean triple? $\endgroup$True
ifn
is a member of any Pythagorean triple?pQ[x,y,z]
is an invalid form, just aspQ[x,z]
would be. ** A simpleSelect[ data, pQ[ #] &]
is how it will be called. $\endgroup$