Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Suggested answer wrong?

  1. #1
    Member
    Join Date
    Oct 2021
    Posts
    63
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Suggested answer wrong?

    I'm working on the following pb : "Write a Java program to create a two-dimension array (m x m) A[][] such that A[i][j] is true if I and j are prime and have no common factors, otherwise A[i][j] becomes false." from https://www.w3resource.com/java-exer...ercise-158.php

    As an answer output they suggested that we should get the following :
    true true true 
    true true true 
    true true false

    I disagree with the answer because iteration (i,j) here will be between 0, 1, and 2. But 0 and 1 are not prime numbers so any value of the matrix with 0 and/or 1 should give false since the first condition is not met (prime number).
    Then, 2 is a prime number but has a common factor (which is 2) if we reach the last value of the matrix[2][2] so how come they suggested this answer. I believe it should only be false? Or am I missing something?

    This solution confuses me in knowing what the right answer is. What do you think of what I said?
    Last edited by siid14; July 18th, 2022 at 01:26 PM.

  2. #2
    Member
    Join Date
    Jun 2022
    Posts
    41
    Thanks
    1
    Thanked 3 Times in 2 Posts

    Default Re: Suggested answer wrong?

    Last edited by AngleWyrm; July 13th, 2022 at 03:05 AM.

  3. #3
    Member
    Join Date
    Oct 2021
    Posts
    63
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: Suggested answer wrong?

    Oh my bad. here is the right link : https://www.w3resource.com/java-exer...ercise-158.php and I just updated my post
    Last edited by siid14; July 18th, 2022 at 01:26 PM.

  4. #4
    Junior Member
    Join Date
    Dec 2022
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Suggested answer wrong?

    Thanks for this interesting solution!

Similar Threads

  1. Replies: 3
    Last Post: March 9th, 2013, 07:22 PM
  2. How to show a question again when a wrong answer is entered?
    By Henk in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 15th, 2012, 02:02 PM
  3. Replies: 9
    Last Post: August 30th, 2012, 03:25 PM
  4. my code displaying some minor wrong o/p ....plz suggest me an answer !
    By naved in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 28th, 2011, 11:59 AM

Tags for this Thread