i can't believe i understood this at last ! thank you !
@lebaguette5393 Жыл бұрын
Counting prime numbers really calms me down
@LimeWitness5 жыл бұрын
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; }
@swan49594 жыл бұрын
i guess you dont need to use break; for if statement, pls correct me if i am wrong
@Anixmusics3 жыл бұрын
thankx a lot for this tutorial video
@PunmasterSTP3 жыл бұрын
Prime numbers? More like prime-time, because this should be shown to more people!
@londonsystem66224 жыл бұрын
The Best
@balladictz29755 жыл бұрын
Hello sir iam no. 1 fun of your channel sir
@flipper44444 жыл бұрын
you wanna tell me why your channel name is Ball Adictz
@thefluffles63842 жыл бұрын
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 Жыл бұрын
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-kc7xq5 жыл бұрын
Very confusing
@jadoaesra30113 жыл бұрын
0 and 1 are and are not prime according to different definitions. Yeaaaah. The history of math is annoying.
@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