Skip to main content
add explanation
Source Link
Sundar R
  • 6.6k
  • 19
  • 33

Perl 5 -p, 23 bytes

$_=eval=~s/..//r eq$_+0

Try it online!

Takes the fractional part alone as input (as allowed by OP), outputs 1 for true and nothing for false.

$_=       # assign to be printed by -p
eval      # evaluate fraction to get 0.something, for eg. 0.54
=~s/..//r # remove the 0. part, giving 54
 eq       # string equality check
$_+0      # after first coercing input to number to remove / and denominator

The decimal part taken by itself would be exactly equal to the numerator only when the denominator is the immediate next power of ten greater than the numerator, which is the condition we need to check for.

Perl 5 -p, 23 bytes

$_=eval=~s/..//r eq$_+0

Try it online!

Takes the fractional part alone as input (as allowed by OP), outputs 1 for true and nothing for false.

Perl 5 -p, 23 bytes

$_=eval=~s/..//r eq$_+0

Try it online!

Takes the fractional part alone as input (as allowed by OP), outputs 1 for true and nothing for false.

$_=       # assign to be printed by -p
eval      # evaluate fraction to get 0.something, for eg. 0.54
=~s/..//r # remove the 0. part, giving 54
 eq       # string equality check
$_+0      # after first coercing input to number to remove / and denominator

The decimal part taken by itself would be exactly equal to the numerator only when the denominator is the immediate next power of ten greater than the numerator, which is the condition we need to check for.

Source Link
Sundar R
  • 6.6k
  • 19
  • 33

Perl 5 -p, 23 bytes

$_=eval=~s/..//r eq$_+0

Try it online!

Takes the fractional part alone as input (as allowed by OP), outputs 1 for true and nothing for false.