magic.prime: Magic squares prime order

Description Usage Arguments Details Author(s) Examples

Description

Produces magic squares of prime order using the standard method

Usage

1
magic.prime(n,i=2,j=3)

Arguments

n

The order of the square

i

row number of increment

j

column number of increment

Details

Claimed to work for order any prime p with (p,ij)=1, but I've tried it (with the defaults for i and j) for many composite integers of the form 6n+1 and 6n-1 and found no exceptions; indeed, they all seem to be panmagic. It is not clear to me when the process works and when it doesn't.

Author(s)

Robin K. S. Hankin

Examples

1
2
3
4
5
6
7
magic.prime(7)
f <- function(n){is.magic(magic.prime(n))}
all(sapply(6*1:30+1,f))
all(sapply(6*1:30-1,f))

is.magic(magic.prime(9,i=2,j=4),give.answers=TRUE)
magic.prime(7,i=2,j=4)

magic documentation built on Feb. 9, 2022, 1:07 a.m.