ScratchData LogoScratchData
Back to ivan321's profile

Prime or Not Prime

IVivan321•Created August 8, 2018
Prime or Not Prime
16
12
323 views
View on Scratch

Instructions

This project asks you to provide a number, identifies all of its whole number factors, and determines whether the number is prime or not prime (i.e. composite). Click the green flag to start and enter a number. Press space to enter a new number. Press up or down arrow to add or subtract 1 from the previous number.

Description

The code simply divides the number by every integer between 2 and the number's square root. Divisors that produce no remainder are added to the factors list. If the factors list contains only 1 and the number itself, the number is determined to be prime, unless the number is 1, which is generally agreed not to be prime. There's a big list of prime numbers here: https://primes.utm.edu/lists/small/10000.txt

Project Details

Project ID238561624
CreatedAugust 8, 2018
Last ModifiedOctober 7, 2024
SharedAugust 11, 2018
Visibilityvisible
CommentsAllowed