Skip to main content
added 20 characters in body
Source Link
jqkul
  • 2.3k
  • 1
  • 18
  • 24

Python >=3.5, 6476 64 58 bytes

Thanks to LeakyNun for golfing off 12 (!) bytes.

Thanks to Sp3000 for golfing off 6 bytes.

import math
lambda n:sum(math.gcd(n,x)<2for x in range(n))

I love how readable Python is. This makes sense, even through the golfedness.

Python >=3.5, 64 bytes

Thanks to LeakyNun for golfing off 12 (!) bytes.

Thanks to Sp3000 for golfing off 6 bytes.

import math
lambda n:sum(math.gcd(n,x)<2for x in range(n))

I love how readable Python is. This makes sense, even through the golfedness.

Python >=3.5, 76 64 58 bytes

Thanks to LeakyNun for golfing off 12 (!) bytes.

Thanks to Sp3000 for golfing off 6 bytes.

import math
lambda n:sum(math.gcd(n,x)<2for x in range(n))

I love how readable Python is. This makes sense, even through the golfedness.

added 45 characters in body
Source Link
jqkul
  • 2.3k
  • 1
  • 18
  • 24

Python 3>=3.5, 64 bytes

Thanks to LeakyNun for golfing off 12 (!) bytes.

Thanks to Sp3000 for golfing off 6 bytes.

from fractionsimport import*math
lambda n:sum(math.gcd(n,x)<2for x in range(n))

I love how readable Python is. This makes sense, even through the golfedness.

Python 3, 64 bytes

Thanks to LeakyNun for golfing off 12 (!) bytes.

from fractions import*
lambda n:sum(gcd(n,x)<2for x in range(n))

I love how readable Python is. This makes sense, even through the golfedness.

Python >=3.5, 64 bytes

Thanks to LeakyNun for golfing off 12 (!) bytes.

Thanks to Sp3000 for golfing off 6 bytes.

import math
lambda n:sum(math.gcd(n,x)<2for x in range(n))

I love how readable Python is. This makes sense, even through the golfedness.

shaved off 12 bytes - thanks, @LeakyNun
Source Link
jqkul
  • 2.3k
  • 1
  • 18
  • 24

Python 3, 7564 bytes

Thanks to LeakyNun for golfing off 12 (!) bytes.

from fractions import*
lambda n:lensum([x forgcd(n,x)<2for x in range(1,n+1)if gcd(n,x)<2])

I love how readable Python is. This makes sense, even through the golfedness.

Python 3, 75 bytes

from fractions import*
lambda n:len([x for x in range(1,n+1)if gcd(n,x)<2])

I love readable Python is. This makes sense, even through the golfedness.

Python 3, 64 bytes

Thanks to LeakyNun for golfing off 12 (!) bytes.

from fractions import*
lambda n:sum(gcd(n,x)<2for x in range(n))

I love how readable Python is. This makes sense, even through the golfedness.

Source Link
jqkul
  • 2.3k
  • 1
  • 18
  • 24
Loading