Free Republic
Browse · Search
General/Chat
Topics · Post Article

To: Skywise

“AI can’t program, PRODUCE or create new ideas.”

‘Write a program for finding prime nujbers’

GEMINI

def is_prime(n):
“””Returns True if n is a prime number, False otherwise.”””
if n <= 1:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True

def find_primes(limit):
“””Returns a list of prime numbers up to the given limit.”””
prime_numbers = []
for i in range(2, limit + 1):
if is_prime(i):
prime_numbers.append(i)
return prime_numbers

# Example usage: Find prime numbers up to 100
primes_up_to_100 = find_primes(100)
print(”Prime numbers up to 100:”, primes_up_to_100)

# Example usage: Find prime numbers up to 50
primes_up_to_50 = find_primes(50)
print(”Prime numbers up to 50:”, primes_up_to_50)

Explanation:
* is_prime(n) function:
* Takes an integer n as input.
* Returns False if n is less than or equal to 1 (because 1 and numbers less than 1 are not prime).
* Iterates from 2 up to the square root of n. If n is divisible by any number in this range, it’s not prime, and the function returns False.
* If the loop completes without finding a divisor, n is prime, and the function returns True.
* find_primes(limit) function:
* Takes an integer limit as input.
* Creates an empty list prime_numbers.
* Iterates from 2 up to limit.
* For each number, it calls the is_prime() function to check if it’s prime.
* If is_prime() returns True, the number is appended to the prime_numbers list.
* returns the list of prime numbers.
* Example Usage:
* The code demonstrates how to use the find_primes() function to find prime numbers up to 100 and 50.
* The results are printed to the console.


13 posted on 03/16/2025 7:06:14 PM PDT by TexasGator (X1.1111'1'./iI11 .I1.11.'1I1.I'')
[ Post Reply | Private Reply | To 9 | View Replies ]


To: TexasGator

Woooow - because no programmer has ever come up with a program to produce prime numbers before?

Still voting RINO?


34 posted on 03/16/2025 8:52:47 PM PDT by Skywise
[ Post Reply | Private Reply | To 13 | View Replies ]

To: TexasGator

I like you and I like your insightful posts, so don’t take this personally. That program is idiotic. It doesn’t get the concept of prime.

Instead of testing all the numbers up to sqrt(n) test all the primes previously found up to sqrt(n), then when you ran out of primes < sqrt(n) start on the next integer. As the n increases, for any positive integer N you pick there is an M such that for n>M my program will be N times as fast as yours/Gemeni’s. And I feel pretty certain my suggestion isalso not the fastest.

Your example supports Stephen Wolfram’s observation that LLMs start out innumerate. They continue sequences of words using markov chain probabilities and if the model is not large enough you see they sound exactly like Kamala Harris word salad.

As a psysics, programmer, lifetime computer engineer and EE/Computer PE, life taught me if you can write a good program to do anything you want, and it does everything the customer requested, you are only a small part of the way there.

1)Requirements are hard to extract from people. If you ask people what they want and do it, most of the time they say “that’s what I said but that isn’t what I want” and change it. (documented study)

2)If it is fast and good it will change the process because they start running it way more times in analysis, such as designing different ways or doing tax returns different ways.

3} Users will conflate the UI with the program logic

4) Every program needs to be tightly integrated with subject matter experts to handle process escapes as times snd facts change.

5) You will constantly have to argue what your work does versus what someone else can promise.


41 posted on 03/16/2025 10:45:00 PM PDT by takebackaustin
[ Post Reply | Private Reply | To 13 | View Replies ]

Free Republic
Browse · Search
General/Chat
Topics · Post Article


FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson