Ramanujan: 1729 and beyond

View source: R/Ramanujan.R

RamanujanR Documentation

1729 and beyond

Description

Finds all the numbers <= Nmax that can be expressed as a sum of two positive integer cubes in at least k distinct ways.

Usage

Ramanujan(Nmax, k=2)

Arguments

Nmax

Limit the search to numbers <= Nmax.

k

Number of distinct ways the returned numbers can be expressed as a sum of two positive integer cubes.

Value

A data frame with columns N, n1, and n2. Columns n1 and n2 show the decomposition of N as the sum of two positive integer cubes i.e. they are such that n1^3 + n2^3 == N.

Author(s)

Hervé Pagès

References

https://en.wikipedia.org/wiki/1729_(number)

https://en.wikipedia.org/wiki/Taxicab_number

Examples

## Find numbers <= 2e4 expressible as the sum of two cubes
## in 2 distinct ways:
Ramanujan(Nmax=2e4, k=2)

## Find numbers <= 2e8 expressible as the sum of two cubes
## in 3 distinct ways:
Ramanujan(Nmax=2e8, k=3)

## Ramanujan(1e13, k=4) will find the 4th taxicab number
## (6963472309248, denoted Ta(4)) in < 30s on a machine
## with enough RAM (it uses about 12.5Gb of memory):
## Not run: 
Ramanujan(1e13, k=4)

## End(Not run)

hpages/Ramanujan documentation built on Sept. 28, 2024, 9:48 a.m.