Skip to main content
added 36 characters in body
Source Link
Robin Ryder
  • 15.8k
  • 2
  • 25
  • 71

R, 2727 25 bytes

-1 byte thanks to Giuseppe

2-sum1+all(!sqrt(scan()+1:2)%%1^.5%%1) 

Try it online!Try it online!

Uses the fact that \$s_n=1\$ iff \$n+1\$ or \$n+2\$ is a perfect square.

R, 27 bytes

2-sum(!sqrt(scan()+1:2)%%1) 

Try it online!

Uses the fact that \$s_n=1\$ iff \$n+1\$ or \$n+2\$ is a perfect square.

R, 27 25 bytes

-1 byte thanks to Giuseppe

1+all((scan()+1:2)^.5%%1) 

Try it online!

Uses the fact that \$s_n=1\$ iff \$n+1\$ or \$n+2\$ is a perfect square.

Source Link
Robin Ryder
  • 15.8k
  • 2
  • 25
  • 71

R, 27 bytes

2-sum(!sqrt(scan()+1:2)%%1) 

Try it online!

Uses the fact that \$s_n=1\$ iff \$n+1\$ or \$n+2\$ is a perfect square.