Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!

rose khf

+ Follow
since Sep 23, 2013
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by rose khf

fred rosenberger wrote:

rose khf wrote:then how I can found largest sum of primes in diagonal ???

How would you do it with pencil and paper?

I don't know you have to tell me otherwise why I put the question
6 years ago
here is first step which is to cheak if number is prime or not using if statement [package primespiral;

import java.util.Scanner;

public class Primespiral {

* @param args the command line arguments
public static void main(String[] args) throws FileNotFoundException {
Scanner infile = new Scanner(new FileReader(""));
PrintWriter outfile = new PrintWriter("spiral.out");
//define limit
int size = 100;

//loop through the numbers one by one
for (int i = 0; i < 100; i++) {
boolean isPrime = true;
//check to see if the number is prime
for (int j = 2; j < i; j++) {
if (i % j == 0) {
isPrime = false;
// print the number
if (isPrime) {
outfile.print(i + " ");



then how I can found largest sum of primes in diagonal ???
6 years ago
Hi there

iam new member in this website and my first topic

I have question in prime spiral
here is question :
Write a JAVA program that takes one or more values for N on the command line
where N is always an odd number in the range 0 < N < 100.
For each N, your program must determine the largest sum of primes along any
diagonal straight line in a grid of size NxN. Write the answer on a separate line,
in the form:
N: S
where N is the grid size, S is the largest sum. For example, given 3 and 5 on the
command line, your program should print:
3: 10
5: 49

also it has two files "" which contain input (2,3,5),and "spiral.out" (49,10)
how I can write code for this question ???
plzz help me
6 years ago