I want to make program for verifying huckels rule, which will tell whether the compound is aromatic or not based of electrons. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I want to make program for verifying huckels rule, which will tell whether the compound is aromatic or not based of electrons.

Rule is like if the compound has (4n+2) pi electrons in delocalized orbit, where n=1,2,3,4..., Then the compound is aromatic. I can create a input where user will enter number of pi electrons, but what about the numerical condition? I programmed that if a is no. of electrons entered, how do I code for is "a" equal to 4n+2 where n is 1,2,3,4... ? In CPP and python?

4th May 2020, 1:12 PM
Chaitanya's Stuff
Chaitanya's Stuff - avatar
2 Answers
+ 6
You should loop from 0 until either 4n+2 = a or 4n+2>a If it is equal, good it's aromatic. If not, 4n+2 > a, nope it isn't :) It'll be easier to implement it in a while-loop than a for-loop, in my opinion but it boils down to your preference. Try it, if you still aren't unable to get it right, we'll provide you with the code but first try. ^^
4th May 2020, 2:16 PM
Nikhil
Nikhil - avatar
+ 1
Please do a try by yourself first. Put the code in playground and save it. If you struggle, you can come back and link your code here so that we can help you. Thanks!
4th May 2020, 1:51 PM
Lothar
Lothar - avatar