diff --git a/algorithms/Java/Maths/nearlyLuckyNumberCF.java b/algorithms/Java/Maths/nearlyLuckyNumberCF.java new file mode 100644 index 00000000..5f87eb6c --- /dev/null +++ b/algorithms/Java/Maths/nearlyLuckyNumberCF.java @@ -0,0 +1,18 @@ +import java.util.*; +public class nearlyLuckyNumberCF { + public static void main(String args[]){ + Scanner in = new Scanner(System.in); + long n = in.nextLong(); + int count = 0; + while(n > 0){ + if(n % 10 == 4 || n % 10 == 7){ + count++; + } + n = n/10; + } + if(count == 7 || count == 4) + System.out.print("YES"); + else + System.out.print("NO"); + } +}