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 Revisions

1 of 3
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina 0.8.2, 73 bytes

.+
$*
^.$|^((.)+)(?=1円*$)(?<=..)(?<!^3円+(..+))(?!((?<-2>1円)+)(?(2)^)4円*$)

Try it online! Link includes test cases. Outputs 0 for a Guiga number, 1 if not. Explanation:

.+
$*

Convert n to unary.

^.$|

Special-case 1, as all of its prime factors satisfy the relation but it's not composite so it's excluded.

^((.)+)

Match an integer p=1円, but also as a count 2円, where...

(?=1円*$)

... p must be a factor of n, ...

(?<=..)

... p must be at least 2, ...

(?<!^3円+(..+))

... p must not have a nontrivial proper factor 3円, and...

(?!((?<-2>1円)+)(?(2)^)4円*$)

... n-p must not be divisible by p2, which is calculated by matching 1円 2円 times, and then captured, so that it can be easily repeated using 4円.

Neil
  • 184.4k
  • 12
  • 76
  • 290

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