Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7809489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:27:05+00:00 2026-06-02T03:27:05+00:00

What I need to accomplish is, I have an array, 2 3 4 5

  • 0

What I need to accomplish is,

I have an array, 2 3 4 5 6 7 8 9 10

I need to check if any numbers in the array divides any other number in the array perfectly. (%=0) If yes, unset the the number.

Its over my head and I cant get it working and everything I tried gives me infinite loops and its making me ill. (lol)

I am not including any codes, because all I could come up with is a nested forloop which doesnt work 🙁

So here is a sample :

Input array :2 3 4 5 6 7 8

Output = 5 6 7 8

Any idea guys?

UPDATE:

Cracked the nut myself with bit more debugging. (Incase if that can be helpful for someone in future.)

// use array_unique, array_values and $size = sizeof($array)
for ($i = 0; $i < $size; $i++)
{
for ($j = $size - 1; $j > $i; $j--)
    if ($numbers[$j] % $numbers[$i] == 0)
    {
        unset($numbers[$i]);
        break;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T03:27:06+00:00Added an answer on June 2, 2026 at 3:27 am

    I will not do this in real code, just because I think you want to do that yourself.

    LoopA iterating the intput array:
      LoopB iterating the input array:
        check division of loopA value and loopB value, and add the value of loopA to a new array accordingly
      End loopB
    End loopA
    Print the new array
    

    Note: This is not complete, but it certainly should give you a start on how to continue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a class where I need accomplish the equivalent of the following
Using PHP I need I will have an array of tag name => tag
I have a python class, and I need to add an arbitrary number of
I have a NSMutableArray and I need to sort its elements into separate C
I have a model tied to an array controller. I need to be able
I have a small amount of structured data and I need to accomplish three
I have an array of numbers that potentially have up to 8 decimal places
I have two array I need to merge, and using the Union (|) operator
I have an array of string-encoded hex values. I need to convert those strings
I have an array of rows from a database I need to sort by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.