'Uramfs Prime Spiral Pattern by T. Nishikawa 2002/10/28 Sub northp() n = ActiveCell.Offset(1).Value x = ActiveCell.Offset(1).Column y = ActiveCell.Offset(1).Row i = 0 Do While Cells(y, x + i) > 0 Cells(y - 1, x + i) = n + i + 1 If prime(n + i + 1) Then Cells(y - 1, x + i).Interior.Color = RGB(255, 0, 0) End If i = i + 1 Loop Cells(y - 1, x + i).Select End Sub Sub eastp() n = ActiveCell.Offset(, -1).Value x = ActiveCell.Offset(, -1).Column y = ActiveCell.Offset(, -1).Row i = 0 Do While Cells(y + i, x) > 0 Cells(y + i, x + 1) = n + i + 1 If prime(n + i + 1) Then Cells(y + i, x + 1).Interior.Color = RGB(255, 0, 0) End If i = i + 1 Loop Cells(y + i, x + 1).Select End Sub Sub southp() n = ActiveCell.Offset(-1).Value x = ActiveCell.Offset(-1).Column y = ActiveCell.Offset(-1).Row i = 0 Do While Cells(y, x - i) > 0 Cells(y + 1, x - i) = n + i + 1 If prime(n + i + 1) Then Cells(y + 1, x - i).Interior.Color = RGB(255, 0, 0) End If i = i + 1 Loop Cells(y + 1, x - i).Select End Sub Sub westp() n = ActiveCell.Offset(, 1).Value x = ActiveCell.Offset(, 1).Column y = ActiveCell.Offset(, 1).Row i = 0 Do While Cells(y - i, x) > 0 Cells(y - i, x - 1) = n + i + 1 If prime(n + i + 1) Then Cells(y - i, x - 1).Interior.Color = RGB(255, 0, 0) End If i = i + 1 Loop Cells(y - i, x - 1).Select End Sub Sub uram_spiral_run() m = InputBox("񐔁H") For j = 1 To m eastp southp westp northp Next j End Sub Function prime(v) ec = js.Set("temp", v) prime = jcmd("1 = # q: temp") End Function