Skip to content

learn-co-students/prime-ruby-001-prework-web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Implementing Prime

Objectives

  1. Practice iteration and looping.
  2. Practice defining methods and controlling return values.

Instructions

Fork and clone this repository. Run the test suite to learn what is required of you.

You'll be defining a method, prime?(), that takes in an integer argument and returns a boolean of whether or not that integer is a prime number.

A few things to think about:

  • What defines an integer as a prime number? Research algorithms for how to determine if a number is prime.
  • How do you create a range of numbers? How do you turn a range into an array so that it can be iterated over?

Requirements:

  • Do not use any other Ruby library. You must build a method that can verify whether a number is prime. Don't require 'math' and just piggyback off their implementation of prime number.

Advanced

Think about the efficiency of your algorithm. How many iterations does it do? Look into Benchmarking in Ruby and profile a few different approaches to implementing prime?().

Resources

View Prime? Lab on Learn.co and start learning to code for free.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages