Skip to main content
added 24 characters in body
Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

R, 8888 87 bytes

p=2;for(y in 3:scan())p=c(p,y[all(y%%y[sum(3!y%%2:y-1))]<2]);for(z in p)cat(z,"*"[2%in%abs(z-p)]," ")

Try it online!Try it online!

I wanted to try a different approach to Xi'an's answer...

Frustratingly, though, after golfing & golfing I still can't get rid of that last pesky byte...Frustratingly, though, after golfing & golfing I still can't get rid of that last pesky byte... Got it!

R, 88 bytes

p=2;for(y in 3:scan())p=c(p,y[all(y%%(3:y-1))]);for(z in p)cat(z,"*"[2%in%abs(z-p)]," ")

Try it online!

I wanted to try a different approach to Xi'an's answer...

Frustratingly, though, after golfing & golfing I still can't get rid of that last pesky byte...

R, 88 87 bytes

p=2;for(y in 3:scan())p=c(p,y[sum(!y%%2:y)<2]);for(z in p)cat(z,"*"[2%in%abs(z-p)]," ")

Try it online!

I wanted to try a different approach to Xi'an's answer...

Frustratingly, though, after golfing & golfing I still can't get rid of that last pesky byte... Got it!

Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

R, 88 bytes

p=2;for(y in 3:scan())p=c(p,y[all(y%%(3:y-1))]);for(z in p)cat(z,"*"[2%in%abs(z-p)]," ")

Try it online!

I wanted to try a different approach to Xi'an's answer...

Frustratingly, though, after golfing & golfing I still can't get rid of that last pesky byte...