Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Random Number Generator | R Loops Tutorial
Control Flow in R

bookChallenge: Random Number Generator

Tâche

Swipe to start coding

Write a function that generates random numbers between 0 and 1 until one is greater than 0.95, returning the number of attempts needed.

  • Start a counter for the number of attempts.
  • Use a repeat loop to generate a random number between 0 and 1.
  • If the random number is greater than 0.95, exit the loop.
  • Return the total number of attempts.

Solution

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 6
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

close

bookChallenge: Random Number Generator

Glissez pour afficher le menu

Tâche

Swipe to start coding

Write a function that generates random numbers between 0 and 1 until one is greater than 0.95, returning the number of attempts needed.

  • Start a counter for the number of attempts.
  • Use a repeat loop to generate a random number between 0 and 1.
  • If the random number is greater than 0.95, exit the loop.
  • Return the total number of attempts.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 6
single

single

some-alt