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

deleted 46 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56

Java (JDK), 4054 bytes

n->n==6|n==28|n==496|n==8128|n==33550336

Try it online!

It contains all the perfect numbers that an int can represent. So why not?


And here an actual computation entry, which counts for 54 bytes:

n->{int s=0,d=0;for(;++d<n;)s+=n%d<1?d:0;return s==n;}

Try it online!

Though for a strict number by number matching, the following will return the same values, but is only 40 bytes.

n->n==6|n==28|n==496|n==8128|n==33550336

Try it online!

Java (JDK), 40 bytes

n->n==6|n==28|n==496|n==8128|n==33550336

Try it online!

It contains all the perfect numbers that an int can represent. So why not?


And here an actual computation entry, which counts for 54 bytes:

n->{int s=0,d=0;for(;++d<n;)s+=n%d<1?d:0;return s==n;}

Try it online!

Java (JDK), 54 bytes

n->{int s=0,d=0;for(;++d<n;)s+=n%d<1?d:0;return s==n;}

Try it online!

Though for a strict number by number matching, the following will return the same values, but is only 40 bytes.

n->n==6|n==28|n==496|n==8128|n==33550336

Try it online!

added 103 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56

Java (JDK), 5440 bytes

n->n==6|n==28|n==496|n==8128|n==33550336

Try it online!

It contains all the perfect numbers that an int can represent. So why not?


And here an actual computation entry, which counts for 54 bytes:

n->{int s=0,d=0;for(;++d<n;)s+=n%d<1?d:0;return s==n;}

Try it online!


Java (JDK) , 40 bytes

n->n==6|n==28|n==496|n==8128|n==33550336

Try it online!

Because why not?

Java (JDK), 54 bytes

n->{int s=0,d=0;for(;++d<n;)s+=n%d<1?d:0;return s==n;}

Try it online!


Java (JDK) , 40 bytes

n->n==6|n==28|n==496|n==8128|n==33550336

Try it online!

Because why not?

Java (JDK), 40 bytes

n->n==6|n==28|n==496|n==8128|n==33550336

Try it online!

It contains all the perfect numbers that an int can represent. So why not?


And here an actual computation entry, which counts for 54 bytes:

n->{int s=0,d=0;for(;++d<n;)s+=n%d<1?d:0;return s==n;}

Try it online!

added 616 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56

Java (JDK), 54 bytes

n->{int s=0,d=0;for(;++d<n;)s+=n%d<1?d:0;return s==n;}

Try it online!


Java (JDK) , 40 bytes

n->n==6|n==28|n==496|n==8128|n==33550336

Try it online!

Because why not?

Java (JDK), 54 bytes

n->{int s=0,d=0;for(;++d<n;)s+=n%d<1?d:0;return s==n;}

Try it online!

Java (JDK), 54 bytes

n->{int s=0,d=0;for(;++d<n;)s+=n%d<1?d:0;return s==n;}

Try it online!


Java (JDK) , 40 bytes

n->n==6|n==28|n==496|n==8128|n==33550336

Try it online!

Because why not?

Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading

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