/prime-ruby-v-000

Primary LanguageRubyOtherNOASSERTION

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 this lesson on Learn.co