MathBabbler Number Analyst (MBNA)

MathBabbler started doing a good amount of BABbling about numbers, so during March of 2008 he began writing C++ (and C) programs to help analyze numbers. This collection of programs evolved into the MBNA (MathBabbler Number Analyst).

Some of the MBNA programs were written during lectures at Scottsdale Community College and many of them have been used as instructional material.

  1. ProperDivisors [created 7 March 2008]
    Prints proper divisors of n; prints a count of proper divisors; prints if n is deficient, proper, abundant; prints abundance ratio.
  2. Fibonacci [created 27 March 2008] Prints if n is a Fibonacci number.
  3. HappyUnhappy [created 8 March 2008] Prints if n is a Happy or Unhappy number.
  4. Harshad [created 7 March 2008] Prints if n is a Harshad number.
  5. PrimeComposite [created 10 March 2008]
    Prints if n is prime or composite. If n is prime, prints cousin primes if any; prints safe primes if any; prints sexy primes if any; prints sexy triplet primes if any; prints sexy quadruple primes if any; prints Sophie Germain primes if any; prints Truman Gerald primes if any; prints if n is Pythagorean prime; prints if n is Eisenstein prime; prints if n is Gaussian prime; prints if n is star prime; prints if n is reversible prime; prints if n is super prime; prints if n is left-truncable prime; prints if n is right-truncable prime.
  6. Undulating [created 25 March 2008] Prints if n is an undulating number.
  7. NearestSquareNumbers [created 20 March 2008] If n not square, prints nearest square numbers < and > n.
  8. NumberSystems [created 09 March 2008] Prints n in base-2, base-8, base-16. Prints if n in base-2 is evil or odious. Prints if n in base-2 is palindromic.
  9. PrimeFactors [created 09 March 2008]
    If n is composite, prints prime factors of n and their sums; prints if n is semi-prime or sphenic; prints if n is a joke (Smith) number; prints if n is a hoax number.
  10. SqrtLnLog [created 09 March 2008] Prints sqrt(n), ln(n), log(n).
  11. PrimeTripletsQuadruplets [created 03 April 2008] If n is prime, prints prime triplets if any; prints prime quadruplets if any.
  12. PerfectRoots [created 14 April 2008] Prints the perfect roots of n if any.
  13. Padovan [created 16 December 2008] Prints if n is a Padovan number.
  14. RomanNumeral [created 22 December 2008] If n < 4000, prints n as a Romal Numeral
  15. ApocalypticPower [created 12 January 2009] Prints if n is an apocalyptic power.
  16. Pronic [created 30 January 2009] Prints if n is a pronic number.
  17. Thabit [created 12 March 2009] Prints if n is a Thabit number.
  18. Palindrome [created 31 March 2009] Prints if n is palindromic.
  19. RuthAaronPairs [created 31 March 2009] Prints if n is in a Ruth-Aaron pair.
  20. Lucky [created 02 May 2009] Prints if n is a lucky number.
  21. SumOfCubes [created 09 May 2009] Prints if n is the sum of three distinct cubes.
  22. BaseNequivalents [created 10 June 2009] Prints n in other number systems.
  23. RepeatingDigit [created 16 June 2009] Prints if all digits of n are the same.
  24. Narcissistic [created 09 July 2009] Prints if n is a narcissistic number.
  25. ThurmNumber [created 20 July 2009] Prints if floor(n/20) and n%20 are primes.
  26. Zuckerman [created 01 August 2009] Prints if n is a Zuckerman number.
  27. Triangular [created 08 October 2009] Prints if n is a triangular number.
  28. Leyland [created 15 October 2009] Prints if n is a Leyland number.
  29. format [created 15 October 2009] Program used to create nBAB collections. mbna_program | format
  30. ConsecutivePrimes [created 24 November 2009] If n is the sum of two or more consecutive primes, the consecutive primes are printed.
  31. Lucas [created 19 December 2009] Prints if n is a Lucas number.
  32. SquareDiffs [created 06 February 2010]
    Finds the x value for an odd number input n that satisfies (x+1)^2-x^2 and (x+1)+x. It also finds the x value for an even number input n that is a multiple of 4 that satisfies (x+1)^2-(x-1)^2 and 2(x+1 + x-1)
  33. Pentagonal [created 12 March 2010] Prints if n is a pentagonal number.
  34. SquareFree [created 06 December 2011] Prints if n has or doesn't have square number divisors.
  35. Kaprekar Number [created 01 June 2012] Prints if n is a Kaprekar number.
  36. SumOfCubes [created 13 August 2012] Prints if n is the sum of three distinct cubes.
  37. Octahedral [created 25 February 2013] Prints if n is an octahedral number.
  38. Dodecagonal [created 23 April 2013] Prints if n is a dodecagonal or centered dodecagonal number.
  39. Powerful [created 30 November 2013] Prints if n is a powerful number.
  40. A117746 [created 20 February 2014] Prints if n is in OEIS integer sequence A117746.
  41. Mersenne [created 26 March 2014] Prints if n is a Mersenne number.
  42. Harmonic [created 28 April 2014] http://oeis.org/A001599
  43. A038853 [created 08 May 2014] Prints n if its divisible by 5 and is the difference between two (different positive) cubes.
  44. X in X [created 04 July 2014] Prints the proper divisors of n that are in the decimal representation of n.
  45. Arithmetic [created 31 December 2014] Prints n if it is an Arithmetic number.
  46. Nude [created 16 May 2015] Prints n if it is an Nude number. n is Nude if the digits of n are factors of n.
  47. Lychrel [created 30 August 2015] Prints if n is a potential Lychrel number.
  48. Moran [created 30 March 2016] Prints if n is a Moran number.
Deprecated
  1. EvilOdious [created 4 March 2008] Prints if n in base-2 is evil or odious. Functionality now in NumberSystems.
  2. EisensteinPrime [created 07 April 2009] Prints if n is an Eisenstein prime. Functionality now in PrimeComposite.
Number Notes
apocalyptic power
An apocalyptic power is a number n such that 2^n contains 666.

arithmetic
The number n is an Arithmetic number if the average of its divisors is an integer.

centered & non-centered dodecagonal
A dodecagonal is a number that is generated by the expression 5n^2-4n. A centered dodecagonal is a number generated by the expression 6n^2+6n+1.

deficient or perfect or abundant
Sum the proper divisors for a number. If the sum equals the number, then the number is perfect. If the sum is less than the number, then the number is deficient; otherwise, the number is abundant.

Eisenstein prime
An Eisenstein prime adheres to the form: 3n-1, where n is an integer.

evil or odious
A number is evil if its binary representation has an even number of 1's; otherwise, the number is odious.

Fibonacci
A number is a Fibonacci number if it is in the Fibonacci sequence of numbers (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, ...).

Friedman
OEIS.org::A083509 "Friedman numbers: can be written in a nontrivial way using their digits and the operations + - * / ^ and concatenation of digits (but not of results)." Smallest Friedman number is 25 (5^2) followed by 121 (11^2), 125 (5^(1+2)), 126 (21*6), 127 (2^7-1), 128 (2^(8-1), 153 (3*51), and so on. {Stetson.edu::MathMagic Friedman number}

Gaussian Prime
OEIS.org::A002145 A Gaussian prime is of the form 4n + 3.

happy or unhappy
A number is happy if iterating through the sum of the squares of the digits of the number eventually evaluates to one. An unhappy number is a number that's not happy.

Harshad
OEIS.org::A005349 A number is a Harshad (or Niven) number if the sum of its digits is a factor (i.e. proper divisor) of the number.

hoax
From MathWorld.Wolfram.com: A hoax number is a "composite number defined analogously to a Smith number except that the sum of the number's digits equals the sum of the digits of its distinct prime factors (excluding 1)."

Kaprekar
A number 'n' is a Kaprekar number if when squared its product has an even number of digits and the sum of the numbers that result from splitting the product is the number 'n'.

Leyland
Leyland numbers are of the form x^y+y^x.

Lucas
A number is a Lucas number if it is in the Lucas sequence of numbers (2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521,...)

Lucky
Lucky numbers are produced from a sieve that adheres to the following algorithm: Start with the natural numbers. Delete every 2nd number, leaving 1 3 5 7 ...; the 2nd number remaining is 3, so delete every 3rd number, leaving 1 3 7 9 13 15 ...; now delete every 7th number, leaving 1 3 7 9 13 ...; now delete every 9th number; etc. [source: OEIS.org]

Lychrel
OEIS.org: "Positive integers which apparently never result in a palindrome under repeated applications of the function f(x) = x + (x with digits reversed)."

Moran
A number is a Moran number if it results in a prime number when divided-by the sum of its digits.

Narcissistic
OEIS.org: A number is narcissistic if "n-digit numbers equal to sum of n-th powers of their digits." (1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474, 54748, 92727...).

Octahedral
Octahedral numbers are the sequence of integers generated by the expression (2*n^3+n)/3.

Odd Square (Centered Octagonal Numbers)
Odd Squares are odd numbers that are also square numbers. The Odd Squares integer sequence is generated by the expression (2n+1)^2. Odd Square checking added to the MBNA on 16 December 2013.

Padovan
A number is a Padovan number if it is in the Padovan sequence of numbers (1, 1, 1, 2, 2, 3, 4, 5, 7, 9, 12, 16, 21, 28, 37, 49, 65, 86, 114, 151, 200, 265...).

palindromic
A number is palindromic if reversing the digits equals the original number. 101 is palindromic and so is 12021.

pentagonal
A number 'n' is pentagonal if (sqrt(24n+1)+1)/6 evalutes to an integer.

powerful
Powerful numbers are generated using the formula a2b3, where a ≥ 1 and b ≥ 1.

prime triplet
A prime triplet is a set of three prime numbers of the form {p, p+2, p+6} or {p, p+4, p+6}.

prime quadruplet
A prime quadruplet is four prime numbers of the form {p, p+2, p+6, p+8}.

pronic number
A pronic (oblong) number is a number which is the product of two consecutive integers, that is, n (n + 1).

repdigit number
A repdigit number (in a particular base) is a number consisting of all the same digits (e.g. 11, 777, 4444...).

Ruth-Aaron pair
A Ruth-Aaron pair consists of two consecutive integers for which the sums of the prime factors of each integer are equal.

safe prime pair
OEIS.org: "Safe primes p: (p-1)/2 is also prime."

sexy prime pair
A sexy prime pair are two prime numbers that differ by six.

Smith number
A number is a Smith number if the sum of its digits equals the sum of the digits of its prime factors.

Squarefree number
A number is a Squarefree number if it is not evenly divisable by a square number n such that n ≥ 4.

sum-product number
A number is a sum-product number if the sum of its digits times the product of its digits equals the number.

super prime
A number is a super prime if it is prime number and if it resides in a prime numbered slot given a list of prime numbers. The first super prime is 3 (it is the 2nd prime number and 2 is prime), the second super prime is 5 (it is 3rd prime number). 7 is not a super prime because it is the 4th prime number and 4 is not prime).

Thabit number
A Thabit number is in the sequence generated by 3 * 2^n - 1, where 0 <= n < infinity.

ThurmNumber
A ThurmNumber is a number that has a prime score and prime plus number when represented in score plus number format.

triangular
The nth triangular number is generated by by formula n(n+1)/2.

undulating
A number is undulating if it has an 'aba...' pattern. The numbers 1-99 are trivial undulating numbers. The first non-trivial undulating number is 101.

Zuckerman
A Zuckerman is a number that has a proper divisor that is the product of its digits.
Internals

The MBNA programs can be executed either as stand-alone programs or as a part of other applications. The mbna program itself is a shell script that executes the collection of MBNA programs.

MBNA programs get their inputs via command-line arguments. Some of the programs get their inputs interactively if no command-line argument is specified.

When applicable, the source code for the MBNA programs contain hyperlinks into the OEIS (Online Encyclopedia of Integer Sequences).

Most of the MBNA programs can be executed to generate a list of the first few numbers of their type (i.e. Fibanocci, Padovan, powerful, lucky, etc.).

The MBNA checks for Friedman numbers, but does so using a table lookup instead of computation.

Needed Modifications

Multiple MBNA programs check numbers for primeness; however, each source file contains its own implementation of an isprime(n) function. This function needs to be made into a library function that is linked into each program that uses it, or it should be defined as a macro that is placed into a local header file and compiled into the program.


Creator: Gerald Thurman [gthurman@gmail.com]
Created: 18 April 2008

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 United States License.