Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Added explanation
Source Link
DLosc
  • 40.7k
  • 6
  • 87
  • 142

Python 2, 57 bytes

n=1
exec"while n==int(.0+n):n+=1\nprint n;n+=1\n"*input()

Starting from 1 takes a very long time. For testing purposes, starting at \2ドル^{53}\$ gives the same results but much quicker.: Try it online!

We count up values of n (an integer) until we find one for which converting to a float (by adding .0) and back to an int doesn't result in the same number. We then print that value and go to the next n. An exec loop lets us do this a fixed number of times according to the input.

Python 2, 57 bytes

n=1
exec"while n==int(.0+n):n+=1\nprint n;n+=1\n"*input()

Starting from 1 takes a very long time. For testing purposes, starting at \2ドル^{53}\$ gives the same results but much quicker. Try it online!

Python 2, 57 bytes

n=1
exec"while n==int(.0+n):n+=1\nprint n;n+=1\n"*input()

Starting from 1 takes a very long time. For testing purposes, starting at \2ドル^{53}\$ gives the same results but much quicker: Try it online!

We count up values of n (an integer) until we find one for which converting to a float (by adding .0) and back to an int doesn't result in the same number. We then print that value and go to the next n. An exec loop lets us do this a fixed number of times according to the input.

Source Link
DLosc
  • 40.7k
  • 6
  • 87
  • 142

Python 2, 57 bytes

n=1
exec"while n==int(.0+n):n+=1\nprint n;n+=1\n"*input()

Starting from 1 takes a very long time. For testing purposes, starting at \2ドル^{53}\$ gives the same results but much quicker. Try it online!

AltStyle によって変換されたページ (->オリジナル) /