Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9073917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:31:30+00:00 2026-06-16T18:31:30+00:00

Possible Duplicate: Find out 20th, 30th, nth prime number. (I’m getting 20th but not

  • 0

Possible Duplicate:
Find out 20th, 30th, nth prime number. (I’m getting 20th but not 30th?) [Python]
Fastest way to list all primes below N in python

prime numbers :

P=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, …] 

fibonacci numbers :

F=[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …] 

i want the user to give a random number between (1,100000) and the program to summarize the result (F[n]+P[n])for example if n=3 F[3]+P[3]=7+2=9

i have written the following code :

import math
def F(n):
    return int(((1+math.sqrt(5))**n-(1-math.sqrt(5))**n)/(2**n*math.sqrt(5)))
L=[]
L.append(2)
L=[]
for n in range(2, 10000):
    for x in range(2, n):
        if n % x == 0:
            break
    else:
        # loop fell through without finding a factor
        L.append(n)

while True:
    x = raw_input().strip()
    if x == "END" or x == "end":
        break
    else:
        num = int(x)
        print F(num)+L[num]

it easy for me to find the Fib numbers just from the def F(n) ,but creating the prime numbers list is really a headache cause as the numbers increase it take some time for the list to be created,and making almost impossible to reach the n into those huge numbers..i tried to make a def not to creating the list butjust calculating the prime number just for the n provided by the user.any ideas??

thank you in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T18:31:30+00:00Added an answer on June 16, 2026 at 6:31 pm

    For Prime Numbers, there are several primality tests that you can implement. I like the naive methods, checking up to sqrt(n), there is also the Sieve of Erathostenes as Marcus Stuhr pointed out. You can optimize it a little bit if you check only the primality of odd numbers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: In Ruby, how do I find out if a string is not
Possible Duplicate: Find out the 'line' (row) number of the cursor in a textarea
Possible Duplicate: How to find out the arity of a method in Python For
Possible Duplicate: for x in y, type iteration in python. Can I find out
Possible Duplicate: How to find out where a function is defined? get filename of
Possible Duplicate: On iPhone: Find out what song is currently playing? (in the iPod
Possible Duplicate: How to find out where a function is defined? I am working
Possible Duplicate: JSON Parsing in Android As I find out I need to use
Possible Duplicate: Easiest way to find duplicate values in a JavaScript array Javascript array
Possible Duplicate: Algorithm to find the total number of connected sets in a matrix

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.