DEV Community

Cover image for Twin Primes and Divisible by 11
Ebenezer
Ebenezer

Posted on

Twin Primes and Divisible by 11

Hey guys

Good day...

Continuation to the previous blog . Today I solved two tasks which is assigned by our trainer. These programs taught me how to use functions and where to use functions and another one is to thoroughly understand the modulo and float logic .

Ok first things first

1 .Twin Prime

Firstly the logic is simple we need to check the number is prime if the number is prime add it with 2 after adding pass the numbe to function to check that is also prime. That's how I thinks logic eventhough I'm weak in syntax stuff I did the program with trial and errror method

Output :

2.Divisible by 11

This problem we need to filter the number because the divisibility rule for 11 is Sum of alternative digits is either by 11 or Zero

So for example the number is 675433 so after the sum of alternative digits the answer is 14 and 14 and If we subtract it result will be zero
Another example is **272822 **so after the sum of alternative digits the answer is 17 and 6 If we subtract that the result is 11

Code :


Output :

So that's all about today's blog , Please adjust my English coz I'm very weak in grammar . I will learn and improve .

Let's see in next blog - Different tasks and Different Blog...

Top comments (0)