C Programming Tutorial 72 - Counting Prime Numbers (Part 1)

  Рет қаралды 15,898

Caleb Curry

Caleb Curry

Күн бұрын

Пікірлер: 14
@bassemhodhod8226
@bassemhodhod8226 2 жыл бұрын
i can't believe i understood this at last ! thank you !
@lebaguette5393
@lebaguette5393 Жыл бұрын
Counting prime numbers really calms me down
@LimeWitness
@LimeWitness 5 жыл бұрын
Hey man. So I gave it a try before watching the rest of the videos for this mini-program and here is what I came up with. It may not be perfect and clean but hey, it does what the boss asked for! Looking forward to seeing your solution now :) /* Create a program that takes input from a user and output all prime numbers between 0 and the user input. At the end, output how many prime numbers there are */ #include int main(void) { int i, input, k, sum, notPrime, isPrime; printf("This program will calculate which numbers are prime between 0 and your choice and output the total number of prime numbers in this range. "); printf("Enter a number: "); scanf("%d", &input); for(i = input; i > 1; i--) { for(k = i - 1; k > 1; k--) { sum = i % k; if(sum == 0) { //printf("%d is not prime ", i); break; } } if (sum != 0) { printf(" %d is a prime number ", i); isPrime++; } } printf(" There is a total of %d prime numbers between %d and 2 inclusive", isPrime, input); return 0; }
@swan4959
@swan4959 4 жыл бұрын
i guess you dont need to use break; for if statement, pls correct me if i am wrong
@Anixmusics
@Anixmusics 3 жыл бұрын
thankx a lot for this tutorial video
@PunmasterSTP
@PunmasterSTP 3 жыл бұрын
Prime numbers? More like prime-time, because this should be shown to more people!
@londonsystem6622
@londonsystem6622 4 жыл бұрын
The Best
@balladictz2975
@balladictz2975 5 жыл бұрын
Hello sir iam no. 1 fun of your channel sir
@flipper4444
@flipper4444 4 жыл бұрын
you wanna tell me why your channel name is Ball Adictz
@thefluffles6384
@thefluffles6384 2 жыл бұрын
Came here because i am doin a course on udemy and can copy the code word for word and i can kinda put 2 and 2 together but i need more details before i move on this is irking me thought a prime number was supposed to come out 0 when using modulus but only 2 times as prime numbers have only two factors but when i look at codes that work the fact that the modulus answer is 0 is a bad thing and i just don't get it. So let's see if this video can explain it to me cause i just can't copy code and move on.
@nik-jz6vk
@nik-jz6vk Жыл бұрын
If the modulus is 0, it means that an integer divides evenly into it. For example, 6%3 = 0. That means that 6 is a multiple of 3. So let's assume p is a prime number. Then p%i will never be equal to zero for any integer i. If p%i is zero, then p is not prime.
@anilvlog-kc7xq
@anilvlog-kc7xq 5 жыл бұрын
Very confusing
@jadoaesra3011
@jadoaesra3011 3 жыл бұрын
0 and 1 are and are not prime according to different definitions. Yeaaaah. The history of math is annoying.
@nik-jz6vk
@nik-jz6vk Жыл бұрын
I tried to do it myself. I think it works? #include #include #include int main() { /* Take an integer input. Print all prime numbers from 1 to input. Print the amount of prime numbers from 1 to input. To compile: gcc primeCounter.c -o primeCounter -lm */ int input; printf("Welcome to the Prime Counter! Enter a number for the prime counter : "); scanf("%d",&input); int i; int k; bool isComposite; int number_of_primes = 0; for(i=2;i
啊?就这么水灵灵的穿上了?
00:18
一航1
Рет қаралды 32 МЛН
Зу-зу Күлпаш 2. Бригадир.
43:03
ASTANATV Movie
Рет қаралды 631 М.
А что бы ты сделал? @LimbLossBoss
00:17
История одного вокалиста
Рет қаралды 6 МЛН
Flipping Robot vs Heavier And Heavier Objects
00:34
Mark Rober
Рет қаралды 17 МЛН
C Programming Tutorial 88 - Function Design
9:09
Caleb Curry
Рет қаралды 22 М.
C Programming Tutorial 86 - Intro to Strings and Null Character
6:47
C Programming Tutorial 96 - Passing by Value vs Pointer
5:17
Caleb Curry
Рет қаралды 36 М.
C# prime numbers program - Simple step by step guide
12:28
tutorialsEU
Рет қаралды 19 М.
Coding Challenge 167: Ulam Spiral of Prime Numbers
24:13
The Coding Train
Рет қаралды 753 М.
C Program To Find Factorial of a Number using Recursion
10:24
Technotip
Рет қаралды 43 М.
C Program To Find Prime Numbers From 2 To N, using For Loop
5:54
Check If A Number Is Prime | C Programming Example
11:57
Portfolio Courses
Рет қаралды 12 М.
Plastic Makers Have A Big Secret: They’re Experimenting On You
15:35
More Perfect Union
Рет қаралды 235 М.
Special Programs in C − Check If The Number Is Prime Number
10:26
Neso Academy
Рет қаралды 139 М.
啊?就这么水灵灵的穿上了?
00:18
一航1
Рет қаралды 32 МЛН