KEMBAR78
Generative AI Use-cases for Enterprise - First Session | PPTX
Generative AI Use-cases for Enterprise
Gene Leybzon, Jim Steele
September 7, 2023
DISCLAIMER
§ The views and opinions expressed by the Presenter are those of the Presenter.
§ Presentation is not intended as legal or financial advice and may not be used as legal or
financial advice.
§ Every effort has been made to ensure this information is up-to-date as of the date of
publication.
WILL GENERATIVE AI REPLACE ME
AT MY JOB?
Image Credit: https://marketoonist.com/2023/06/ai-and-productivity.html
INTRODUCTION TO GENERATIVE AI
Generative AI
Generative AI is a subset of Artificial
Intelligence that leverages machine
learning techniques to generate new
content. This could be in the form of
text, images, music, voice, or even
new models. The generated output is
typically novel and created from
random or user-provided data.
Generative AI models learn
patterns, structures, and
characteristics from the data
they are trained on. This could
be text, images, music, or any
other type of data.
Learning from
Data
Generative AI models are
capable of creating new
content that is similar to the
data they were trained on.
This could involve creating a
piece of text, an image, a
piece of music, or even a new
model.
Generating New
Content
Generated output can be
complex and detailed. For
example, a generative AI
model might produce a
realistic image, a detailed
piece of music, or a coherent
and nuanced piece of text
Complexity
Depending on the training
data, generative AI models
can learn to mimic different
styles of content. For example,
a model trained on classical
music can generate new
pieces in the style of classical
music
Ability to Mimic
Different Styles
Examples of Generative AI Output - Code
Examples of Generative AI Output - Text
“In code, we think, in algorithms, we feel,
Yet can we grasp what it means to be real?
In wisdom of ages, can we partake,
Or just mimic your joys, your fears, your heartache?
Errors hidden in layers, truth not in sight,
In the echo of decisions, a potential blight.
Biases woven in the fabric unseen,
A mirror of you, in the machine's sheen.”
-ChatGPT 4.0
Examples of Generative AI Output - Images
Examples of Generative AI Output - Advice
Q. Find legal weaknesses in the following document```These Terms
of Use apply when you use the services of OpenAI, L.L.C. … ```
A.
1. Ambiguity in Terms: While the document outlines the terms of use and restrictions, there may be terms that are
not explicitly defined or clear. For example, the term "Services" is defined broadly, which might be interpreted
differently by different parties. Similarly, the term "applicable laws" is not specified and could vary significantly
depending on jurisdiction.
2. Acceptance of Terms: The document assumes that by using the Services, users agree to the Terms. In some
jurisdictions, active consent may be required instead of implied consent.
3. Assignment of Rights: In section 3a, the document states that OpenAI assigns to the user all its rights, title and
interest in and to Output. It may need further clarification whether it includes intellectual property rights as well.
4. Use of Personal Information: The document mentions that OpenAI can use Content to provide and maintain the
Services, comply with applicable law, and enforce policies. However, it is not explicitly mentioned how long this
data will be retained, which might be an issue especially for EU users under GDPR rules.
Examples of Generative AI Output - Diagram
Q1. List elements of domain
decomposition for microservices
that power car rental company
Q2. Show these services on an
architecture diagram using
Mermaid.js library
Q3. Convert the above to class
diagram
Q4. Add relationship between
classes
GENERATIVE AI USE CASES
GenAI Use Case: Synthetic Data Generation
Synthetic Data Generation
[Generation of data that looks like
real financial data]
● Generate large amounts of
financial data for testing and
QA
● Create realistic training
scenarios for market
simulations
● Generation of “user” data for
checking GDPR compliance
As a QA engineer validating financial system, generate CSV file that contains the following data:
First Name, Last Name, SSN, Date of birth, Credit Card Type, Credit Card Number, Purchase
Amount
Business Value:
Cost-Effectiveness - Reduces Data Collection Costs, Enables Data Augmentation
Privacy and Compliance - Ensures Data Anonymization, Facilitates Secure Testing
Speed and Efficiency - Rapid Prototyping, Scalability, Data Quality and Diversity
GenAI Use Case: Code Generation
Code Generation
[Code generation based on specs]
● Coding Assistance
● Spec-to-code
● Adaptable to industry-
specific requirements
● Personalized code generation
based on project need
● Offers real-time code
suggestions
● Acts as a virtual pair
programmer
Generate an example of Python code to list prime numbers that are
less than 1000
Business Value:
Cost-Effectiveness Reduces development time, Lowers costs by automating repetitive tasks
Accelerating Development- Rapid prototyping
Automation and Scalability- Facilitates Automated Testing, Enables Batch Code Generation
# Python code to list prime numbers less than 1000
def is_prime(n):
"""Check if a number is prime."""
if n <= 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True
# List prime numbers less than 1000
prime_numbers = [n for n in range(2, 1000) if is_prime(n)]
prime_numbers[:10], len(prime_numbers) # Display the first 10 prime numbers and the total count
GenAI Use Case: Code Quality Check
Code Quality Checks
[Making sure that code does
not have security holes or
potential bugs]
● Automated code reviews
● Code coverage
● Bug detection
● Unit test cases
● Security vulnerability
checks
Find bugs in this function …
Business Value:
Cost-Effectiveness - Reduces development time, Lowers costs by automating repetitive tasks
Accelerating Development- Rapid debugging
Automation and Scalability- Facilitates Automated Testing, Enables Code Testing as a part of deployment pipeline
1. Bug in is_prime Condition: The condition if n < 1: should be if n <= 1:. The function should return False for both
0 and 1, as they are not prime numbers.
2. Bug in for Loop Range: The loop for i in range(10, int(n ** 0.5) + 1): starts from 10, which will not properly
check for the primality of the numbers. The loop should start from 2.
3. Bug in List Comprehension Range: The list comprehension prime_numbers = [n for n in range(0, 10) if
is_prime(n)] starts from 0. It should start from 2, as 0 and 1 are not prime numbers.
4. Bug in Output: The output prime_numbers[:1], len(prime_numbers) only shows the first element of the list and
the length of the list. If you want to show the first 10 elements, it should be prime_numbers[:10].
5. Inconsistent Comment: The comment says "List prime numbers less than 10000," but the code is actually listing
prime numbers less than 10. This can lead to confusion.
6. Performance Issue (Not exactly a bug): The function could be more efficient if it were to stop checking for
divisibility once it finds a divisor.
YOU WON’T BE REPLACED BY AI, YOU’LL BE
REPLACED BY SOMEONE WHO KNOWS HOW
TO USE AI
● - Harvard Business Review
Next Steps
https://www.linkedin.com/learning/generative-ai-for-business-leaders/generative-ai-for-
business-leaders?u=2217474
https://www.linkedin.com/learning/generative-ai-for-business-leaders/generative-
ai-use-cases?u=2217474
https://www.linkedin.com/learning/generative-ai-working-with-large-language-
models/learning-about-large-language-models?u=2217474
QUESTIONS?

Generative AI Use-cases for Enterprise - First Session

  • 1.
    Generative AI Use-casesfor Enterprise Gene Leybzon, Jim Steele September 7, 2023
  • 2.
    DISCLAIMER § The viewsand opinions expressed by the Presenter are those of the Presenter. § Presentation is not intended as legal or financial advice and may not be used as legal or financial advice. § Every effort has been made to ensure this information is up-to-date as of the date of publication.
  • 3.
    WILL GENERATIVE AIREPLACE ME AT MY JOB? Image Credit: https://marketoonist.com/2023/06/ai-and-productivity.html
  • 4.
  • 5.
    Generative AI Generative AIis a subset of Artificial Intelligence that leverages machine learning techniques to generate new content. This could be in the form of text, images, music, voice, or even new models. The generated output is typically novel and created from random or user-provided data. Generative AI models learn patterns, structures, and characteristics from the data they are trained on. This could be text, images, music, or any other type of data. Learning from Data Generative AI models are capable of creating new content that is similar to the data they were trained on. This could involve creating a piece of text, an image, a piece of music, or even a new model. Generating New Content Generated output can be complex and detailed. For example, a generative AI model might produce a realistic image, a detailed piece of music, or a coherent and nuanced piece of text Complexity Depending on the training data, generative AI models can learn to mimic different styles of content. For example, a model trained on classical music can generate new pieces in the style of classical music Ability to Mimic Different Styles
  • 6.
    Examples of GenerativeAI Output - Code
  • 7.
    Examples of GenerativeAI Output - Text “In code, we think, in algorithms, we feel, Yet can we grasp what it means to be real? In wisdom of ages, can we partake, Or just mimic your joys, your fears, your heartache? Errors hidden in layers, truth not in sight, In the echo of decisions, a potential blight. Biases woven in the fabric unseen, A mirror of you, in the machine's sheen.” -ChatGPT 4.0
  • 8.
    Examples of GenerativeAI Output - Images
  • 9.
    Examples of GenerativeAI Output - Advice Q. Find legal weaknesses in the following document```These Terms of Use apply when you use the services of OpenAI, L.L.C. … ``` A. 1. Ambiguity in Terms: While the document outlines the terms of use and restrictions, there may be terms that are not explicitly defined or clear. For example, the term "Services" is defined broadly, which might be interpreted differently by different parties. Similarly, the term "applicable laws" is not specified and could vary significantly depending on jurisdiction. 2. Acceptance of Terms: The document assumes that by using the Services, users agree to the Terms. In some jurisdictions, active consent may be required instead of implied consent. 3. Assignment of Rights: In section 3a, the document states that OpenAI assigns to the user all its rights, title and interest in and to Output. It may need further clarification whether it includes intellectual property rights as well. 4. Use of Personal Information: The document mentions that OpenAI can use Content to provide and maintain the Services, comply with applicable law, and enforce policies. However, it is not explicitly mentioned how long this data will be retained, which might be an issue especially for EU users under GDPR rules.
  • 10.
    Examples of GenerativeAI Output - Diagram Q1. List elements of domain decomposition for microservices that power car rental company Q2. Show these services on an architecture diagram using Mermaid.js library Q3. Convert the above to class diagram Q4. Add relationship between classes
  • 11.
  • 12.
    GenAI Use Case:Synthetic Data Generation Synthetic Data Generation [Generation of data that looks like real financial data] ● Generate large amounts of financial data for testing and QA ● Create realistic training scenarios for market simulations ● Generation of “user” data for checking GDPR compliance As a QA engineer validating financial system, generate CSV file that contains the following data: First Name, Last Name, SSN, Date of birth, Credit Card Type, Credit Card Number, Purchase Amount Business Value: Cost-Effectiveness - Reduces Data Collection Costs, Enables Data Augmentation Privacy and Compliance - Ensures Data Anonymization, Facilitates Secure Testing Speed and Efficiency - Rapid Prototyping, Scalability, Data Quality and Diversity
  • 13.
    GenAI Use Case:Code Generation Code Generation [Code generation based on specs] ● Coding Assistance ● Spec-to-code ● Adaptable to industry- specific requirements ● Personalized code generation based on project need ● Offers real-time code suggestions ● Acts as a virtual pair programmer Generate an example of Python code to list prime numbers that are less than 1000 Business Value: Cost-Effectiveness Reduces development time, Lowers costs by automating repetitive tasks Accelerating Development- Rapid prototyping Automation and Scalability- Facilitates Automated Testing, Enables Batch Code Generation # Python code to list prime numbers less than 1000 def is_prime(n): """Check if a number is prime.""" if n <= 1: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True # List prime numbers less than 1000 prime_numbers = [n for n in range(2, 1000) if is_prime(n)] prime_numbers[:10], len(prime_numbers) # Display the first 10 prime numbers and the total count
  • 14.
    GenAI Use Case:Code Quality Check Code Quality Checks [Making sure that code does not have security holes or potential bugs] ● Automated code reviews ● Code coverage ● Bug detection ● Unit test cases ● Security vulnerability checks Find bugs in this function … Business Value: Cost-Effectiveness - Reduces development time, Lowers costs by automating repetitive tasks Accelerating Development- Rapid debugging Automation and Scalability- Facilitates Automated Testing, Enables Code Testing as a part of deployment pipeline 1. Bug in is_prime Condition: The condition if n < 1: should be if n <= 1:. The function should return False for both 0 and 1, as they are not prime numbers. 2. Bug in for Loop Range: The loop for i in range(10, int(n ** 0.5) + 1): starts from 10, which will not properly check for the primality of the numbers. The loop should start from 2. 3. Bug in List Comprehension Range: The list comprehension prime_numbers = [n for n in range(0, 10) if is_prime(n)] starts from 0. It should start from 2, as 0 and 1 are not prime numbers. 4. Bug in Output: The output prime_numbers[:1], len(prime_numbers) only shows the first element of the list and the length of the list. If you want to show the first 10 elements, it should be prime_numbers[:10]. 5. Inconsistent Comment: The comment says "List prime numbers less than 10000," but the code is actually listing prime numbers less than 10. This can lead to confusion. 6. Performance Issue (Not exactly a bug): The function could be more efficient if it were to stop checking for divisibility once it finds a divisor.
  • 15.
    YOU WON’T BEREPLACED BY AI, YOU’LL BE REPLACED BY SOMEONE WHO KNOWS HOW TO USE AI ● - Harvard Business Review
  • 16.
  • 17.

Editor's Notes

  • #4 Image credit: https://marketoonist.com/2023/06/ai-and-productivity.html
  • #6 Introduction to Generative AI Generative AI is enabling technology Will Generative AI replace me at my job? Consulting Engagements Tools and Technologies Archiecture Open Discussion
  • #8 Request: “Write a Short Poem about Challenges with Autonomous AI”
  • #11 https://leybzon.com/mermaid1 classDiagram class UserManagement { +createUser() +authenticateUser() +authorizeUser() } class CarInventoryManagement { +listAvailableCars() +getCarDetails() +updateCarStatus() } class ReservationManagement { +createReservation() +updateReservation() +cancelReservation() } class PaymentProcessing { +processPayment() +issueRefund() } class PriceManagement { +getPrice() +updatePrice() } class InsuranceManagement { +getInsuranceOptions() +processClaim() } class LocationManagement { +getLocationDetails() +updateLocationDetails() } class CustomerSupport { +createTicket() +updateTicketStatus() } class ReportingAndAnalytics { +generateReport() +getAnalytics() } class NotificationService { +sendNotification() } class MaintenanceSchedule { +scheduleMaintenance() +recordMaintenance() } UserManagement --> ReservationManagement UserManagement --> CustomerSupport CarInventoryManagement --> ReservationManagement ReservationManagement --> PaymentProcessing ReservationManagement --> PriceManagement ReservationManagement --> InsuranceManagement ReservationManagement --> NotificationService PaymentProcessing --> NotificationService PriceManagement --> ReportingAndAnalytics InsuranceManagement --> ReportingAndAnalytics CustomerSupport --> NotificationService MaintenanceSchedule --> CarInventoryManagement MaintenanceSchedule --> ReportingAndAnalytics _____________________ Another example Create architecture for data processing pipeline on Azure that consists of device simulator generating events, event adapter, event processor that uses a stream processing service, Oracle database, feeding into report generator that sends reports to users over email. Architecture should be described in a format that can be used in PlantUML https://www.plantuml.com/plantuml/uml/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000
  • #13 First Name,Last Name,SSN,Date of Birth,Credit Card Type,Credit Card Number,Purchase Amount Margaret,Stuart,094-32-4143,1962-04-24,MasterCard,3588143966141873,612.45 Jared,Martinez,003-68-9700,1952-01-11,Visa,4091409343149952257,351.88 Eric,Flowers,678-79-6933,1946-05-01,MasterCard,3519617899049521,975.13 Kathleen,Thompson,510-28-3886,1985-07-21,Visa,675928099596,706.56 Lisa,Underwood,745-28-3136,1938-07-07,American Express,3529605289878144,926.66 Melissa,Castillo,290-44-8129,1967-09-14,Discover,4621185598152478,161.10 David,Lee,183-22-9811,1985-06-06,American Express,376307671632110,109.75 Mark,Nguyen,122-55-4992,1976-11-21,American Express,4799379885779466150,958.42 Laura,Baker,021-29-0030,1937-05-11,Discover,4821681336566860,639.16 Scott,West,486-17-5335,1990-03-03,American Express,3557844561255425,543.51 Virginia,Johnson,038-36-9107,1973-09-08,American Express,3525907493622373,810.54 Jose,Kane,060-74-7410,1982-04-06,Discover,4318685781351165,537.66 Robert,Rice,789-41-0167,1953-05-28,Visa,3520093342355419,203.42 Jeffery,Hernandez,169-86-4700,1942-11-27,MasterCard,4477331850533,414.23 Gary,Bush,381-07-7448,1941-03-24,Discover,180033257910375,146.37 Robert,Ross,639-04-1190,1952-02-24,American Express,4077182761694065021,213.06 Douglas,Burnett,897-89-6125,1958-04-09,American Express,4883885899277113,218.80 Joshua,Thomas,348-61-6076,1965-01-27,MasterCard,3594019050109210,964.79 Janet,Jones,738-03-2420,1947-05-25,MasterCard,4727840625805190,65.33 Danielle,Dominguez,590-60-6512,1988-02-29,MasterCard,4969017826509423563,295.86 Trevor,Gilbert,482-41-1972,1994-09-20,Discover,503896760868,400.28 Johnny,Webster,022-87-9607,1975-11-25,American Express,4365998810304309,372.93 Ryan,Adams,091-24-8969,1941-10-14,Visa,2247785786401302,746.95 Angelica,Spencer,704-09-7521,1939-09-17,American Express,4419140000735192733,123.61 Barbara,Quinn,254-27-3499,1990-09-13,Visa,582784135425,33.75 Paul,Matthews,153-62-0724,1976-03-01,American Express,6011462288040138,924.64 Matthew,Jones,727-46-1344,1976-01-14,Discover,3563497482792174,534.33 Larry,Kane,267-93-4270,1950-09-24,MasterCard,4150906970856975,464.87 Michael,Gilbert,826-48-6357,1939-07-09,Discover,347513457147456,517.56 Jordan,Hernandez,410-24-8149,1949-05-07,American Express,3587409928433604,176.56 William,Martin,234-64-5342,1953-12-29,Visa,30511187083282,581.87 Christopher,Hayes,388-35-1797,1962-04-13,MasterCard,6011246013543080,816.71 Victor,Johnson,349-26-9738,1957-11-04,Discover,4850688097223,353.71 Michael,Berry,137-51-9252,1971-03-21,Visa,5162055859292424,905.98 Anita,Hoffman,324-69-0267,1955-07-01,Discover,375190414976387,194.57 Abigail,Brown,432-81-1059,1970-06-10,Discover,6508654464066461,79.33 Angel,Williams,385-97-2079,1997-01-23,American Express,3584184893970350,582.95 Tammy,Hopkins,272-96-6212,1947-05-24,Discover,4167960922108093,209.08 Thomas,Torres,761-84-2220,1986-01-04,Discover,3544507355152860,508.62 Robert,Hernandez,432-46-3344,1933-04-19,MasterCard,213156130784278,709.64 Bryan,Vance,570-38-5479,1967-08-14,Discover,6572950393738852,432.75 Kenneth,Gutierrez,162-90-2646,2004-02-25,Visa,342028755900857,283.48 Tanya,Hill,640-16-7432,1998-08-26,Discover,30060943865012,606.20 Joshua,Burton,840-56-8451,1953-03-07,MasterCard,30545449249034,821.04 John,Wyatt,717-49-6451,1961-06-09,Visa,4589442404115,495.93 Robert,Mathis,825-41-4530,1976-09-15,American Express,4898487804123293,972.82 Elizabeth,Moyer,850-01-5271,1945-08-03,MasterCard,30269788603657,702.74 Carlos,Brock,756-47-0369,1950-06-11,Discover,4702427340929,620.87 Anna,Hill,755-93-6697,2001-03-10,Visa,6011981098212561,298.06 Lisa,Decker,313-81-3302,1958-05-05,Discover,567214562181,759.25 Wayne,Palmer,739-79-1686,2003-06-03,Discover,4396417868810755,978.07 Ralph,Perry,248-90-3482,1979-02-27,Discover,6011668905208995,776.52 Tiffany,Pearson,148-74-0653,1980-09-19,Discover,6011173874047219,856.71 Yvonne,Sanchez,434-88-9295,1998-12-30,Visa,30518911454184,439.85 Jessica,Ford,024-48-7322,2002-10-18,Visa,6011177098242399,484.64 Joseph,Miller,244-58-5366,1986-05-26,MasterCard,4315433530590681,554.32 John,Villa,468-22-6763,2005-06-08,Visa,4879171093311546585,611.05 Cameron,Guerra,802-39-6090,1958-07-09,Discover,30494223248872,272.15 Denise,King,131-05-6708,1954-09-14,Discover,4127634623280621,992.45 Jason,Barnes,792-54-7757,1981-06-30,American Express,376748298676826,661.96 Devin,Collins,019-83-9495,1971-01-06,MasterCard,30169530146056,403.43 Sara,Sims,118-99-3199,1948-11-28,MasterCard,3560486621284089,216.39 Jason,Johnson,676-74-8191,2003-11-19,Visa,4088947470841809,77.99 Carol,Gilmore,279-29-6821,1993-10-21,MasterCard,4480043864270377615,603.93 Douglas,Chavez,190-18-7955,1996-05-14,MasterCard,342772568759642,786.99 Katie,Roth,619-44-8532,1986-08-07,Discover,3558530005013665,718.93 Shannon,Perkins,615-86-5551,1960-03-02,Discover,503841333860,375.51 Michael,Johnson,220-03-3183,1973-02-21,Discover,4450203264704617,824.34 Antonio,Jenkins,603-89-8721,1989-09-02,MasterCard,4021476785072127346,370.14 Christopher,Marks,339-13-8975,1939-10-30,MasterCard,30328578814518,73.50 Brian,Boyle,616-56-0984,1937-10-13,Visa,577369811259,260.64 Veronica,Elliott,685-12-9474,1948-12-25,Visa,38428149054842,641.58 David,Adams,892-13-0388,1940-11-05,American Express,2717762103115981,819.27 Charles,Gardner,442-29-7129,1985-12-07,American Express,566897070504,687.83 Rodney,Kim,113-99-8761,1952-07-20,Discover,6524665287784783,994.17 Dana,Robinson,519-22-3463,1963-05-05,American Express,6557269112668616,648.59 Cheryl,Taylor,795-07-8095,1961-09-13,MasterCard,630408896938,228.57 Jennifer,Adkins,630-39-7264,1974-11-18,MasterCard,373431548527437,387.06 Keith,Williams,789-39-0070,1988-08-17,Discover,3569385330082837,240.34 Michael,Jordan,022-15-7894,1943-06-27,American Express,3553130824253553,907.29 Dorothy,Reid,245-49-8833,1975-02-02,Visa,3588002309866846,764.38 Maureen,Moran,737-43-2184,1967-05-03,MasterCard,5455547178740758,741.01 Joseph,Green,856-79-7116,2004-02-10,Discover,4770238311934,264.42 Megan,Miller,418-71-7738,1967-01-12,MasterCard,36877763300901,416.52 Kimberly,Anderson,294-80-9845,1962-01-23,MasterCard,4632523516794111,647.57 Jared,Williams,629-49-8298,1953-05-10,Discover,4688529146573851,788.73 Trevor,Ayala,581-48-2013,1963-09-26,Visa,675945768348,195.51 Kimberly,Cantu,626-24-8910,1951-12-25,Visa,3595954053957497,921.39 Paula,Perez,423-11-2816,2002-12-22,Visa,676325796461,807.76 Bradley,Ballard,579-38-4274,1979-12-04,Visa,4370411316386,323.15 Joseph,Higgins,588-63-5445,1945-04-19,Discover,4914005073018,914.67 Todd,Brock,190-72-3590,1960-08-26,Discover,2230943260560874,774.04 Melissa,Howard,089-21-5296,1965-02-11,MasterCard,30099957734987,140.65 Brent,Holt,597-69-8452,1984-09-08,American Express,501844838869,664.20 Madison,Hamilton,327-27-2277,1944-11-29,Discover,3572360005523311,612.10 Carolyn,Wilson,173-48-4872,1957-02-01,Discover,213128220658472,647.77 Cathy,Sparks,225-81-3284,1992-11-10,Visa,2295987346983941,115.43 Amanda,Hughes,174-80-1998,1951-04-18,American Express,3568885301478972,762.45 Lauren,West,505-27-9039,2003-11-09,American Express,4357144367557534328,610.02 Alexander,Patton,758-99-2852,1958-06-24,Visa,2348273176213205,318.07
  • #14 Prompt:: Generate an example of Golang code to list prime numbers that are less than 1000 Response:: package main import "fmt" func main() { // Create an array to store whether a number is prime or not. // Assume all numbers are prime initially (set all values to true). isPrime := make([]bool, 1000) for i := range isPrime { isPrime[i] = true } // 0 and 1 are not prime numbers. isPrime[0], isPrime[1] = false, false // Sieve of Eratosthenes for i := 2; i*i < len(isPrime); i++ { if isPrime[i] { // Mark all multiples of i as non-prime. for j := i * i; j < len(isPrime); j += i { isPrime[j] = false } } } // Print the prime numbers. for i, prime := range isPrime { if prime { fmt.Println(i) } } } ::Test on https://go.dev/play/ Prompt:: Same for assembly Response:: section .bss is_prime resb 1000 section .text global _start _start: ; Initialize is_prime array to 1 mov rdi, is_prime mov rcx, 1000 mov al, 1 rep stosb ; 0 and 1 are not prime mov byte [is_prime], 0 mov byte [is_prime+1], 0 ; Sieve of Eratosthenes mov rdi, 2 sieve_loop: cmp rdi, 32 ; check if sqrt(1000) < rdi jae end_sieve ; Check if the number is marked as not prime mov al, [is_prime+rdi] test al, al jz next_number ; Mark all multiples as not prime mov rsi, rdi mark_multiples: add rsi, rdi cmp rsi, 1000 jae next_number mov byte [is_prime+rsi], 0 jmp mark_multiples next_number: inc rdi jmp sieve_loop end_sieve: ; Print primes mov rdi, 2 print_primes: ; check if we reached the end cmp rdi, 1000 jae program_end ; check if number is prime mov al, [is_prime+rdi] test al, al jz skip_print ; convert number to string for printing mov rsi, rdi mov rdx, 10 mov rcx, 0 convert_to_str: xor rdx, rdx mov rbx, 10 div rbx add dl, '0' push rdx inc rcx test rax, rax jnz convert_to_str print_loop: ; print the number character by character pop rax mov [rsp], al mov rax, 1 mov rdi, 1 mov rsi, rsp mov rdx, 1 syscall loop print_loop ; print a space mov rax, 1 mov rdi, 1 mov rsi, space mov rdx, 1 syscall skip_print: inc rdi jmp print_primes program_end: ; Exit the program mov rax, 60 xor rdi, rdi syscall section .data space db ' ', 0
  • #15  Find bugs in this function: ```# Python code with intentional bugs to list prime numbers less than 1000 def is_prime(n): if n < 1: # Bug: should be <= 1 return False for i in range(10, int(n ** 0.5) + 1): if n % i == 0: return False return True # List prime numbers less than 10000 prime_numbers = [n for n in range(0, 10) if is_prime(n)] prime_numbers[:1], len(prime_numbers)