Answered step by step
Verified Expert Solution
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
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; iStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started