Sequence of non-squares: Difference between revisions
→{{header|Python}}: Python 2 -> Python 3
(added Ol) |
(→{{header|Python}}: Python 2 -> Python 3) |
||
Line 1,883:
=={{header|Python}}==
<lang python>>>> from math import floor, sqrt
>>> def non_square(n):
>>> print(*map(non_square, range(1, 23)))
▲>>> # first 22 values (as a list) has no squares:
▲[2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27]
>>> # The following check shows no squares up to one million:
>>>
>>> non_squares = map(non_square, range(1, 10 ** 6))
>>> next(filter(is_square, non_squares))
StopIteration Traceback (most recent call last)
<ipython-input-45-f32645fc1c0a> in <module>()
1 non_squares = map(non_square, range(1, 10 ** 6))
----> 2 next(filter(is_square, non_squares))
StopIteration: </lang>
=={{header|R}}==
|