EgyptianFraction class

This class converts a Fraction or a MixedFraction type into its egyptian fraction representation. Only positive number are allowed.

An Egyptian fraction is a finite sum of distinct fractions where the numerator is always 1, the denominator is a positive number and all the denominators differ from each other. For example:

  • 5/8 = 1/2 + 1/8 (where "1/2 + 1/8" is the egyptian fraction)

Basically, egyptian fractions are a sum of fractions in the form 1/x that represent a proper or an improper fraction. Here we have other examples of fractions and their egyptian fraction equivalent:

  • 4/7 = 1/2 + 1/14
  • 43/48 = 1/2 + 1/3 + 1/16
  • 2014/59 = 34 + 1/8 + 1/95 + 1/14947 + 1/670223480

In various cases, the value of the denominator can be so big that an overflow error happens.

Implemented types

Constructors

EgyptianFraction({required Fraction fraction})
Creates an EgyptianFraction instance from a Fraction object.
const
EgyptianFraction.fromMixedFraction({required MixedFraction mixedFraction})
Creates an EgyptianFraction instance from a MixedFraction object.

Properties

fraction Fraction
The fraction to be converted into an egyptian fraction.
final
hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

compareTo(EgyptianFraction other) int
Compares this object to another object.
override
compute() List<Fraction>
Returns a series of Fractions representing the egyptian fraction of the current fraction object.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override