473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

hello i want this phyton code in c language please help me

Expand|Select|Wrap|Line Numbers
  1. def isPrim(n):
  2.     if n <=1 :
  3.         return False
  4.     if n <=3:
  5.         return True
  6.     else:
  7.         for x in range(3,n):
  8.             if(n%x==0):
  9.                 return False
  10.         return True
  11.  
  12. D,P=map(int,input().split())
  13. H=D/P
  14. N=H
  15. c=0
  16. while N>1:
  17.     i=0
  18.     count=0
  19.     while True:
  20.         if isPrim(int((i*H)+N)) and ((i*H)+N)<=D:
  21.             count=count+1
  22.         if i==(P-1): break
  23.         i+=1
  24.     if count == P: c+=1       
  25.     N-=1
  26. print(c)
Prime time again..
Aug 8 '20 #1
1 2905
Banfa
9,065 Expert Mod 8TB
How much C do you know? Some us your attempt, we are not here to do your work for you.

Also at line 7 you have used too wide a range and it makes your code more inefficient than it need be.
Aug 8 '20 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: osfar | last post by:
i want the code 2 make prgress bar 1 moving from 0% to 100% and i want it to take 200 second and after that finish i want msg box appear how please help me im very new
1
by: vbsoft | last post by:
Hello My Name is Mike Am from Nigeria a student of computer Science, Pls i want your You to help in Using VISUAL BASIC 6.0 AND MS SQL SERVER AS DATABASE AS A CLIENT SERVER SIDE pLS: I...
1
by: saravanatmm | last post by:
i want script code for the hover onn the text or images like this url http://www.istockphoto.com/file_search.php?action=file&lightboxID=2351475 Or double click on the text it shows the...
1
by: nagendra padala | last post by:
i want cpp code for packet reordering
0
by: Sitar | last post by:
Hello all, I have serious problem with valgrind errors. Code is 1400lines long :( .so, it is imposible to post it in here. Is it someone able to check my code and help me with that errors. I think...
9
by: gulfam143 | last post by:
hello this my code is not working internet explorer plz give me solution /** * When we click on a card */ $('#btnpay').click(function(){ const paymentRequest = { cardNumber: ...
1
by: paulo91 | last post by:
hi , pls i want a code that prints product expiration days, months and years remaining, i want the code to serve as a count down timer starting from the day the product was registered to the day it...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.