%I #15 May 22 2021 14:25:57
%S 15,20,23,31,32,40,42,45,47,48,53,58,60,61,63,68,73,74,75,76,78,79,87,
%T 88,92,95,96,97,99,106,107,109,110,111,112,116,117,118,120,127,128,
%U 130,131,132,133,135,137,139,140,141,143,150,151,154,156,158,159,161
%N Numbers that can't be expressed as the sum of a square and a Fibonacci number.
%C 0 is considered to be a Fibonacci number.
%e 17 = 16+1, 16 is a square and 1 is a Fibonacci number, so 17 is not in the sequence.
%p q:= proc(n) local f,g; f,g:= 0,1;
%p do if f>n then return true
%p elif issqr(n-f) then return false
%p else f,g:= g,f+g
%p fi od
%p end:
%p select(q, [$0..200])[]; # _Alois P. Heinz_, May 22 2021
%t nn = 161; sq = Range[0, Sqrt[nn]]^2; fb = {}; i = 0; While[f = Fibonacci[i]; f < nn, i++; AppendTo[fb, f]]; fb = Union[fb]; Complement[Range[0, nn], Union[Flatten[Outer[Plus, sq, fb]]]] (* _T. D. Noe_, Jul 31 2012 *)
%o (Python)
%o prpr = 0
%o prev = 1
%o fib = [0]*100
%o for n in range(100):
%o fib[n] = prpr
%o curr = prpr+prev
%o prpr = prev
%o prev = curr
%o for n in range(1234):
%o i = yes = 0
%o while i*i<=n:
%o r = n - i*i
%o if r in fib:
%o yes = 1
%o break
%o i += 1
%o if yes==0:
%o print(n, end=',')
%o (Python)
%o from sympy import fibonacci
%o from itertools import count, takewhile
%o def aupto(lim):
%o fbs = list(takewhile(lambda x: x<=lim, (fibonacci(i) for i in count(0))))
%o sqs = list(takewhile(lambda x: x<=lim, (i*i for i in count(0))))
%o return sorted(set(range(1, lim+1)) - set(f+s for f in fbs for s in sqs))
%o print(aupto(161)) # _Michael S. Branicky_, May 22 2021
%Y Cf. A000045, A000290, A132144, A214412.
%K nonn,easy
%O 1,1
%A _Alex Ratushnyak_, Jul 16 2012
|