Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

87
Views
por favor ayúdenme a resolver un problema con bucles

Tengo que resolver este ejercicio: mostrar todos los números en orden descendente entre 0 y 100, luego mostrar viva cada número primo entre 100 y cero dentro del mismo bucle que muestra los pares decrecientes.

Hice este código:

 for($n=100; $n>0; $n-=1 ){ $tableaunombrepaires[]= $n; //loop for dividers for($j=2; $j<=$n/2; $j++) { $diviseurs[]= $j; } // here we devide foreach($diviseurs as $diviseur){ $restes[]=$n%$diviseur; } if(!(in_array(0,$restes))){ echo "$n hourrah! \n"; } else{ echo "$n \n"; } }

pero no funciona ayuda por favor

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

function isPrime ($n) { for ($x = 2; $x < $n; $x++) { if($n % $x == 0) { return false; } } return true; } for($n = 100; $n > 0; $n--) { if (isPrime($n)) { echo $n . " hourrah! \n"; } else { echo $n . "\n"; } }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!