Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Go language Homework help Prime numbers play an important role in cryptography. The following program generates 10000 random prime numbers and inserts them into a

Go language Homework help

image text in transcribed

image text in transcribed

Prime numbers play an important role in cryptography. The following program generates 10000 random prime numbers and inserts them into a slice. This program would be much more efficient if prime number generation would be done in multiple concurrent threads. Modify this program such that 5 go threads concurrently generate prime numbers and write the results into a channel. The slice is then filled by reading from this channel. Make sure all threads are terminated before ending the program. Check the impact of this change on the execution time. package main import "fmt" import "math" import "time" import "math/rand" // returns true if number is prime func isPrime (v int64) bool { sq:= int 64 (math.Sqrt (float 64 (v) ) ) +1 var i int64 for i=2; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions